gpt4 book ai didi

javascript - postgresql to_timestamp 返回与时间戳表示的日期不同的日期

转载 作者:搜寻专家 更新时间:2023-10-30 20:02:11 24 4
gpt4 key购买 nike

这是问题的复制:

我通过 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com