Convert timestamp to integer and integer to timestamp in Postgres

If you want to convert an integer value into a timestamp in Postgres, you can use the following function:

SELECT to_timestamp(1321398000);

The vice versa conversion can be done with the following line:

select extract(epoch from '2011-11-15 00:00:00+01'::timestamp with time zone)::integer