以下是问题的复制:
我现在通过JavaScript获取时间戳
var ts = +new Date // 1368971991090
console.log( new Date(1368971991090) ); // Sun May 19 2013 13:59:51 GMT+0000 (GMT)
然后在我的Postgres控制台中,
# select to_timestamp(1368971991090);
to_timestamp
--------------------------------
45350-12-30 05:31:29.999872+00
(1 row)
未来的日期太多了。
The docs of JavaScript Date#getTime
说它从纪元开始返回毫秒;与argument type Postgres' to_timestamp
accepts相同。 Java的Date#getTime
返回与JS Date#getTime
相同的值。
答案 0 :(得分:6)
从您的链接中的postgresql文档引用:
它接受双精度参数并从Unix纪元转换 (自1970-01-01 00:00:00 + 00以来的秒数)到时区的时间戳。
键 -
秒以来
在JS doc中:
自1970年1月1日00:00:00 UTC以来的毫秒数