now() vs 'epoch'::timestamp
| От | James Cloos |
|---|---|
| Тема | now() vs 'epoch'::timestamp |
| Дата | |
| Msg-id | m3twwzfzte.fsf@carbon.jhcloos.org обсуждение |
| Ответы |
Re: now() vs 'epoch'::timestamp
Re: now() vs 'epoch'::timestamp Re: now() vs 'epoch'::timestamp |
| Список | pgsql-general |
I've for some time used: (now()::timestamp without time zone - 'epoch'::timestamp without time zone)::reltime::integer to get the current seconds since the epoch. The results are consistant with date +%s. (Incidently, is there a better way in 9.4?) But I found the 'epoch'::timestamp + $THAT_VALUE::reltime was off. I consitantly get 1970-01-01 06:00 plus a fraction of a second from: select now() - ((now()::timestamp without time zone - 'epoch'::timestamp without time zone)::reltime::integer)::reltime; The machines on which I've tried it all have localtime == UTC. Am I missing something obvious? Also, is there any way to get the equiv of date +%s%N as a numeric or a double precision? -JimC -- James Cloos <cloos@jhcloos.com> OpenPGP: 0x997A9F17ED7DAEA6
В списке pgsql-general по дате отправления: