How do I get the current unix timestamp from PostgreSQL? - Database Administrators Stack Exchange

PHOTO EMBED

Tue Aug 09 2022 03:10:57 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

select now(),
       extract(epoch from now()),                                          -- correct
       extract(epoch from now() at time zone 'utc'),                       -- incorrect
       extract(epoch from now() at time zone 'utc' at time zone 'utc');    -- correct

          now                  |    date_part     |    date_part     |    date_part
-------------------------------+------------------+------------------+------------------
 2014-10-14 10:19:23.726908+02 | 1413274763.72691 | 1413267563.72691 | 1413274763.72691
(1 row)


https://www.epochconverter.com/
content_copyCOPY

https://dba.stackexchange.com/questions/2796/how-do-i-get-the-current-unix-timestamp-from-postgresql