解析历史UTC日期时间给出了一个奇怪的时区偏移 [英] Parsing historical UTC date times gives an odd time zone shift
问题描述
在其他应用程序中,我的UTC时间不同.
一些示例 2999-01-30T23:00:00.000Z
或 1699-12-30T23:00:00.000Z
.
我使用JavaScript中的 new Date(date)
将其转换为前端时间.
然后问题出在最终格式中.
新日期("2999-01-30T23:00:00.000Z")
导致 2月1日星期三2999 00:00:00 GMT + 0100
但是 new Date("1699-12-30T23:00:00.000Z")
会导致 Wed Dec 30 1699 23:57:44 GMT + 0057
./p>
为什么突然给我这个输出?为什么会有这种奇怪的时间偏移?
我想知道问题是什么,是否存在任何解决方案?我什么都找不到.
我猜测的日期可能是1699年,您又回到了时区不同的历史中.例如,在丹麦,我们于1894年改用CET,所以我得到了:
新日期("1893-12-31T00:00:00.000Z");//1893年12月31日星期日,格林尼治标准时间+0050(中欧标准时间)新日期("1894-01-01T00:00:00.000Z");//1月1日,星期一1894 01:00:00 GMT + 0100(中欧标准时间)
From a rest application I get different times in UTC.
A few examples 2999-01-30T23:00:00.000Z
or 1699-12-30T23:00:00.000Z
.
I convert it to Time on the front end, using new Date(date)
in JavaScript.
The problem is then in the resulting format.
new Date("2999-01-30T23:00:00.000Z")
results in Thu Jan 31 2999 00:00:00 GMT+0100
, as expected.
But new Date("1699-12-30T23:00:00.000Z")
results in Wed Dec 30 1699 23:57:44 GMT+0057
.
Why does it suddenly give me this output? Why is there this odd time shift?
I wonder what the problem is, whether anything exists to solve this? I could not find anything.
I'm guessing with a date from 1699, you are back in history where timezones were different. For example here in Denmark we switched to CET in 1894, so I get:
new Date("1893-12-31T00:00:00.000Z");
// Sun Dec 31 1893 00:50:20 GMT+0050 (Central European Standard Time)
new Date("1894-01-01T00:00:00.000Z");
// Mon Jan 01 1894 01:00:00 GMT+0100 (Central European Standard Time)
这篇关于解析历史UTC日期时间给出了一个奇怪的时区偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!