5

I'm developing a web tool, and currently running into an issue where on some tabs, I'm getting UTC instead of my proper timezone offset.

ie If I put in the console:

(new Date()).getTimezoneOffset()

I get 0 in some tabs and a value of 420 in other tabs. Even tabs with the exact same website loaded.

When I use getMonth, getDate, getHours etc... the times are all in UTC as well.

I'm new to using getTimezoneOffset, so is this behaviour I should expect? Based on what I'm reading, I think this should be my local time on my PC, which hasn't been changed at all during this process.

Chrome Version 71.0.3578.80 (Official Build) (64-bit)

Is there something I'm doing wrong or is this really a bug I've found in Chrome? I can't seem to find any record of any bug like this. The closest is one specific to Android. https://bugs.chromium.org/p/chromium/issues/detail?id=520783

However, it seems improbable that I'd be the first to find a bug like this, with so many Chrome users. I wanted to make sure that this is definitely a bug.

Here is some additional information:

navigator.userAgent = Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36

Working Tabs:

Intl.DateTimeFormat().resolvedOptions().timeZone = undefined
new Date().toString() = "Mon Dec 24 2018 16:09:55 GMT-0700 (GMT-07:00)"
(new Date()).getTimezoneOffset() = 420
(new Date()).getHours() = 16

Failing Tabs:

Intl.DateTimeFormat().resolvedOptions().timeZone = "Etc/Unknown"
new Date().toString() = "Mon Dec 24 2018 23:09:44 GMT+0000 (GMT)"
(new Date()).getTimezoneOffset() = 0
(new Date()).getHours() = 23

The time changes correctly. Only the timezone is wrong.

It appears to be URL dependent. For example, website URLs that previously failed will fail again if opened in a new tabs.

New tabs do not seem to have the issue, however once I visit a "poisoned" URL, then the timezone is affected on that tab.

Visiting a good URL appears to fix the problem, however visiting about:blank makes no difference.

As an example, if I open a new tab, it works fine. Then I visit stackoverflow.com (currently poisoned) then the timezone is failing. Now I visit stackexchange.com (non-poisoned), and the timezone is fine. Then I visit stackoverflow.com and it's broken again. Now, I go to about:blank, and it's still broken. If I visit stackexchange.com it works again. Then I visit about:blank, the timezone is still correct.

It appears to be domain name specific. For example, every tab which is stackoverflow.com is broken, while every question on stackexchange.com has the right timezone. I have tested at least 7 pages on each URL.

It doesn't affect incognito mode. For example, if I open a new window with Ctrl + Shift + N and then visit stackoverflow.com, the timezone is correct. However, if I open a new window normally Ctrl + N, then the timezone is broken still.

When I first started, I had multiple tabs open to the same site, and some of them were working and some of them failed. If I recall, it was the newest tab that failed first. I could duplicate a working tab and get another tab with that same URL. If I duplicated the failing tab, then I would also get another failing tab. However, I no longer have any working tabs on failing URLs outside of incognito mode.

azoundria
  • 940
  • 1
  • 8
  • 24
  • 1
    Also some Mac bugs https://crbug.com/773532 https://crbug.com/818249 but they're marked as fixed. – Josh Lee Dec 22 '18 at 16:19
  • 1
    Hmmm.. The same question was [asked a few days earlier by someone else](https://stackoverflow.com/q/53815971/634824)... Perhaps there is indeed a bug. I'll ask you for the same details: Please supply the output of `navigator.userAgent`, `Intl.DateTimeFormat().resolvedOptions().timeZone`, and `new Date().toString()`, and tell us also if they differ between a blank tab (url: `about:blank`) and any of the others. Thanks. – Matt Johnson-Pint Dec 23 '18 at 17:10
  • Hi Matt. I have done a lot of testing today and yesterday and updated the question. Hopefully it helps. I plan to restart my PC in the next 30 minutes, which might fix it, so let me know ASAP if you can think of anything else I should try while it's in this state. – azoundria Dec 24 '18 at 23:41
  • 1
    Thanks for the update. From the user agent, I see you are running Chrome 71 (latest) on Windows 7. Have you modified your Windows time zone settings or removed your time zone registry keys? Are you using Windows Update? Read through [this question](https://stackoverflow.com/q/53675594/634824), including the comments and my answer to it. Specifically, check `tzutil /g`, `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation` and `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones`. Does that shed any light on the issue? – Matt Johnson-Pint Dec 26 '18 at 18:03
  • 1
    No settings have been modified in recent history. Windows Update is enabled, and was up to date fairly recently. I'm not aware of any changes to the timezone here. The "Mountain Standard Time" registry key does exist with lots of timezones and I can freely select a timezone in the Control Panel. TimezoneKeyName is Mountain Standard Time. One idea is that it's possible that it could have something to do with restoring a lot of tabs. That's about the only thing I can think of which is out of the ordinary for me. – azoundria Dec 27 '18 at 17:36
  • 1
    Thanks. I will investigate further... – Matt Johnson-Pint Dec 27 '18 at 17:38
  • Awesome. I really appreciate your help. Note that unlike the other reported/linked error, my difference is specific to only tabs with certain websites, and involves UTC instead of any timezone offset, while their issue I assume affects every single website on Chrome the exact same. I still have not restarted and I need to do that. I have a strong suspicion that will fix the problem. – azoundria Dec 27 '18 at 17:45
  • If there's one you can reproduce semi-consistently, can you provide a url? I've tried many and not been able to repro. Then again, perhaps it is specific to Windows 7 - I've only tried on Windows 10, but I'll set up a test VM and see if I can repro it there. – Matt Johnson-Pint Dec 27 '18 at 21:40
  • 1
    I'm having the same issue. Two tabs open to the same url. On one, Intl.DateTimeFormat().resolvedOptions().timeZone returns "Etc/Unknown" and on the other it returns undefined. This property has been wonky every since I did an in-place upgrade from Windows 7 to Windows 10. My other Windows 10 computer returns the correct timezone. – EricP Jan 01 '19 at 01:52
  • tzutil /g the first registry location both show my correct timezone. The second registry location is a list of all timezones. – EricP Jan 01 '19 at 02:06
  • Dwayne, did you happen to be restoring your Chrome tabs from the session before when you upgraded? – azoundria Jan 03 '19 at 00:46

0 Answers0