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.

When Local Clock set to 12AM hour, Chrome returns incorrect TZ values

See original GitHub issue

Describe the bug Steps:

  1. set your local clock time on your machine to the 12AM hour
  2. have a script that loads dayjs and extends utc & timezone
  3. open firefox and run command in console:
  4. open chrome or MS edge and run the same command in console
    dayjs
      .tz(
        dayjs().format('YYYY-MM-DD HH:mm'), // get local date and time
        'America/Los_Angeles'
      )
      .day(2)                               // set it to Tuesday
      .hour(23)                             // set the hour late in the day
      .minute(1)                            // set some random minute
      .tz('America/Chicago')                // now convert it to a tz for the next day (should be wednesday)
      .format(`dddd h:mm A [America/Chicago]`);
    

Expected behavior

  • The day should be set to Wednesday when converting, but Chrome is saying it’s Tuesday.
  • Issue does not happen outside of the 12:00-12:59AM window

Developer_Tools_-Tuesday_2_52_AM_America_Chicago-http___localhost_7177_time-converter_day_2_month_8_hour_23_minute_28_tz_93_otz_51_and_DevTools-localhost_7177_time-converter_day_2_month_8_hour_23_minute_28_tz_93_otz_51_and_Date___Time

Information

  • Day.js Version: 1.8.35
  • OS: MacOS Catalina 10.15.6
  • Browser:
    • Failing Chrome Based browsers:
      • Chrome 85.0.4183.83
      • MS Edge 85.0.564.44
    • Succeeds in Firefox:
      • Firefox 80.0.1
  • Time zone: GMT-07:00 DST (Pacific Daylight Time)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iamkuncommented, Sep 9, 2020

Yes, I can reproduce this issue after changing my system timezone to GMT-07:00 and time to 12:59 AM (yes, it’s available in this locale)

However, I don’t know why there’s a different result between chrome and firefox.

I’ll mark this as a bug and digging it deeply later.

0reactions
beatzballcommented, Sep 8, 2020

although i still think this is a bug, my workaround is that i’ve explicitly defined the time in the beginning to always be 12:00 instead of relying on the local time (which could at some point be between 00:00 and 00:59)

dayjs
  .tz(
    dayjs().format('YYYY-MM-DD [12:00]'), // get local date and force time of 12:00
    'America/Los_Angeles'
  )
  .day(2)                               // set it to Tuesday
  .hour(23)                             // set the hour late in the day
  .minute(1)                            // set some random minute
  .tz('America/Chicago')                // now convert it to a tz for the next day (should be wednesday)
  .format(`dddd h:mm A [America/Chicago]`);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Time display incorrect - Google Chrome Community
On your Windows device, open the settings application. Navigate to Date & time. Under Time zone, select a time zone different from your...
Read more >
17535 - wrong time zone in gmail when using chrome - Monorail
Same problem on Arch Linux using chromium r42934. My time zone is GMT+1, displayed times in GMail and other web applications is 9...
Read more >
Wrong time zone displayed in Calendar when set from network
If I lock an event to a TZ, then it is displayed incorrectly in my current TZ. E.g. I have a 5am flight...
Read more >
Clock displaying incorrect timezone? - Help Center
Clock displaying incorrect timezone? · Type/enter: about:config into your address/URL bar. · Search for the 'privacy.resistfingerprinting' setting ...
Read more >
Incorrect time in Home Assistant, time zone is set correctly ...
Hi everybody, can you please help me correct my settings to actually use to local time? I run a Docker container, where I...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found