question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timezone conversion incorrect when daylight saving in effect

See original GitHub issue

Describe the bug Dayjs does not seem to convert timezone correctly when DST is in effect. It produces different results from Moment. The Moment results seem intuitively what I’d expect, so believe to be correct unless there is some subtlety I’m missing.

Expected behavior With this code:

    const when = '2020-07-30T12:00:00+00:00'; // Midday GMT in summer
    console.log('Moment London: ' + moment(when).tz('Europe/London').format('HH:mm Z'));
    console.log('Moment New York: ' + moment(when).tz('America/New_York').format('HH:mm Z'));

    console.log('Dayjs London: ' + dayjs(when).tz('Europe/London').format('HH:mm Z'));
    console.log('Dayjs New York: ' + dayjs(when).tz('America/New_York').format('HH:mm Z'));

The output is:

    Moment London: 13:00 +01:00
    Moment New York: 08:00 -04:00
    Dayjs London: 12:00 +00:00 // Expect 13:00 +01:00
    Dayjs New York: 08:00 -05:00 // Expect 08:00 -04:00

Information

  • Day.js: v1.9.6
  • OS: Windows 10 Home
  • Nodejs: v12.8.3
  • Time zone: GMT+00:00

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:19
  • Comments:19

github_iconTop GitHub Comments

12reactions
Serg-Moiscommented, Mar 15, 2022

The problem is still relevant.

7reactions
AComasSamclacommented, May 26, 2022

a year and a half after this bug was reported and it’s still no fixed? damn… should i revert to momentjs after all?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time zones that do not observe daylight saving time - Outlook
In the Time zone list, select a time zone that does not observe daylight saving time and has the same UTC offset as...
Read more >
The easy way to deal with time zones and daylight savings time
YES! Say so long to conditional conditions that subtract an amount of time based on the date; AT TIME ZONE handles the switch...
Read more >
Daylight saving time and time zone best practices [closed]
The best advice is to stay away from local times as much as possible and stick to UTC where you can. Only convert...
Read more >
Storing Date/Time as UTC, problem with daylight savings time
If they are traveling, they just change the timezone in their profile and all dates adjust to new timezone + daylight savings time...
Read more >
Converting DATETIME and DATETIME-TZ from UTC to ...
On dates of daylight saving start, during daylight saving hours, converted time is incorrect. On dates of daylight saving end, during daylight ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found