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.