简体   繁体   English

JS时区错误偏移

[英]JS Timezone wrong offset

Alright, so I know date & timezones is basically hell in JS, but I can't figure this out:好吧,所以我知道日期和时区在 JS 中基本上是地狱,但我无法弄清楚:

I have a string which is a RFC3339 date representation: 2020-03-13T19:30:00Z我有一个字符串,它是 RFC3339 日期表示: 2020-03-13T19:30:00Z

I'm in Paris, (UTC+2) so you would expect the LocaleString to be 2020-03-13 21:30:00, but it shows up as 2020-03-13T20:30:00.我在巴黎 (UTC+2),所以您会期望 LocaleString 为 2020-03-13 21:30:00,但它显示为 2020-03-13T20:30:00。

Am I missing something?我错过了什么吗?

PS: I'm using the date-fns library, here is the example code: PS:我使用的是date-fns库,这里是示例代码:

    const value = '2020-03-13T19:30:00Z';

    console.log(value);
    console.log(utcToZonedTime(value, 'Europe/Paris').toLocaleString());

As @Andreas said:正如@Andreas 所说:

2020-03-13 was CET (UTC+1), the switch to CEST has been on 2020-03-29. 2020-03-13 是 CET (UTC+1),切换到 CEST 已于 2020-03-29。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM