这是问题的复制:
我通过 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)
一个太过遥远的 future 。
The docs of JavaScript Date#getTime
说它返回从纪元开始的毫秒数;与 argument type Postgres' to_timestamp
accepts 相同. Java 的 Date#getTime
返回与 JS Date#getTime
相同的值。
最佳答案
从您的链接中引用 postgresql 文档:
it accepts a double precision argument and converts from Unix epoch (seconds since 1970-01-01 00:00:00+00) to timestamp with time zone.
键 -
seconds since
在 JS 文档中:
number of milliseconds since 1 January 1970 00:00:00 UTC
关于javascript - postgresql to_timestamp 返回与时间戳表示的日期不同的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16635581/