Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is new Date() returning the wrong timezone in Chrome? [duplicate]

userAgent:`Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.7 Safari/537.36`

In Chrome Devtools, running new Date(1899, 1, 10) will yield the string:

Fri Feb 10 1899 00:00:00 GMT+0805 (中国标准时间)

But in other browsers it returns:

Fri Feb 10 1899 00:00:00 GMT+0800 (中国标准时间)

0800 is correct. Why does 0805 appear?

like image 319
Gavin Yang Avatar asked Jun 01 '18 09:06

Gavin Yang


1 Answers

Looking at this website, for Shanghai, they had a GMT+0805 from < 1800 up to 1900.

enter image description here

This changed in 1901 when they removed the extra 5 minutes, becoming GMT+0800.

enter image description here

Same reason why user Thum Choon Tat gets GMT+0646. in the comments.

This said, it looks like Chrome goes a little further than other browsers in determining the timezone.

like image 92
Nico Van Belle Avatar answered Sep 30 '22 06:09

Nico Van Belle