The unix epoch timestamp is a number representing the number of seconds since the first of January, 1970. This may seem like a strange representation, but it allows dates to be compared very easily.

To get the epoch timestamp of a date in PostgreSQL, we can use the EXTRACT function like so:

tim=# SELECT EXTRACT(EPOCH FROM NOW());
date_part
------------------
1263253466.68634

  1. Nizam says:

    Thank you! Works perfectly.