MySQL UNIX_TIMESTAMP for PostgreSQL

I am basically trying to convert a date field from my database in a few seconds. I used UNIX_TIMESTAMP in our old MySQL database and looked for an equivalent function in PostgreSQL.

Thanks in advance

+3
source share
2 answers
SELECT extract(epoch FROM your_datetime_column)
FROM your_table

More details in the manual:

http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

+10
source

It:

select CURRENT_TIMESTAMP - '1970-01-01';

Gives you a type interval. You can get seconds from the result of this interval if you need it.

+1
source

All Articles