PostgreSQL Timestamp and Unix Time Conversions

PostgreSQL timestamp to Unix time:
postgres=# select extract(epoch from timestamp with time zone '2011-01-02 03:04:05+06');
 date_part  
------------
 1293915845
(1 row)
Unix time to PostgreSQL timestamp:
postgres=# select to_timestamp(1293915845);
      to_timestamp      
------------------------
 2011-01-01 22:04:05+01
(1 row)

2 comments: