如何在Postgres中将日期时间转换为Unix纪元值?

问题描述:

如何将以下格式转换为UNIX时间戳?

How do I convert the following format to UNIX timestamps?

一个值,如: 2015年1月2日10:20 应该转换为: 1418273999000

A value like: 01-02-2015 10:20 PM should be converted to: 1418273999000

我确实尝试过 to_timestamp 函数,但对我不起作用。

I did try to_timestamp function but its not working for me.

如果您的数据存储在名为ts的列中,在称为数据的表中,执行以下操作:

If your data is stored in a column called ts, in a table called data, do this:

select extract(epoch from ts) from data