简体   繁体   中英

JS Timezone wrong offset

Alright, so I know date & timezones is basically hell in JS, but I can't figure this out:

I have a string which is a RFC3339 date representation: 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.

Am I missing something?

PS: I'm using the date-fns library, here is the example code:

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

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

As @Andreas said:

2020-03-13 was CET (UTC+1), the switch to CEST has been on 2020-03-29.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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