Forgot password?
 Create new account
View 95|Reply 0

getTimezoneOffset() 和历史数据

[Copy link]

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2025-3-5 03:44:03 |Read mode
由于历史原因,一个地区的时区可能会不断变化,即使不考虑夏令时。例如,下面是在上海运行 Javascript 时的输出,时区为 UTC+08:00。
  1. const shModernOffset = new Date("2022-01-27").getTimezoneOffset(); // -480
  2. const shHistoricalOffset = new Date("1943-01-27").getTimezoneOffset(); // -540
Copy the Code

en.wikipedia.org/wiki/Historical_time_zones_of_China
1939 年中日战争期间,全中国采用 UTC +7。在中日战争期间,上海在日本控制下,时区被改为 UTC+09:00 以与日本对齐(实际上是“全年夏令时”),这在 IANA 数据库中有记录。
第二次世界大战后又恢复了五个时区 UTC+05:30、+06:00、+07:00、+08:00、08:30
1949 年中国内战结束后,共产党掌权,全中国采用 UTC+8。

手机版Mobile version|Leisure Math Forum

2025-4-20 11:56 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list