Chrome Javascript date bugChrome Javascript date bug

Posted October 3rd, 2008 in Applications and Javascript (Updated October 24th, 2008)

There is a bug in Google Chrome which causes it to get the date and time wrong in Javascript in some timezones, apparantly only in the southern hemisphere. This post looks at the issue and how I became aware of it only because of using Gmail.

Update October 24th 2008: This issue has been fixed in the latest version of Chrome available in the development channel in the 0.3.x branch. At some point this will filter into the beta channel when it goes from 0.2.x to 0.3.x. Read my "Google Chrome switch to the dev channel" post if you want to change Google Chrome to the dev channel.

Original post continues:

I've been using Gmail for my mail for a few weeks now and I usually use Google's Chrome browser for reading my email (and usually Firefox for doing other web browsing). It's always bugged me that Gmail was always an hour out in the times that are displayed for the messages.

Then one day I was using Firefox to read my email and noticed the times were correct, so I realised there must be something wrong with Chrome.

Sure enough, after some searching of Google I found a couple of posts which show that Chrome has a time zone bug for locations in the southern hemisphere, at least through version 0.2.149.30. Chrome's javascript is adding an extra hour to the offset, and therefore, to all displayed times.

The easiest way to test for the bug is to type the following into your browser address bar and then the <enter> key:

javascript:new Date().toString()

For Chrome, it will show the date and time in the following format as a web page:

Thu Oct 02 2008 17:41:50 GMT+1400 (New Zealand Daylight Time)

Then all you need to do is compare that with the actual date and time so see if it is out. Clearly that's wrong because New Zealand Daylight Time is not GMT+1400 and is actually GMT+1300.

The following are from other browsers, all on Windows, taken within a minute of the above:

Chrome 0.2.149.30: Thu Oct 02 2008 17:41:50 GMT+1400 (New Zealand Daylight Time)

Firefox 3.0.3: Thu Oct 02 2008 16:41:08 GMT+1300 (New Zealand Daylight Time)

Internet Explorer 7.0: Thu Oct 2 16:41:23 UTC+1300 2008

Safari 3.1.2: Thu Oct 02 2008 16:41:39 GMT+1300 (New Zealand Daylight Time)

Although the formatting is a little different for some browsers you can see they all show the same time except for Chrome.

Note that the Javascript used above doesn't output anything in Safari. To make it work you need to do an alert to display a popup dialog window like so instead:

javascript:alert(new Date().toString())

An annoying bug which I hope they fix soon. A bug report has been filed which you can read here on the Google Chromium pages.

Related posts:

Comments

blog comments powered by Disqus