Tuesday, January 17, 2012

Wrong date and time in Gmail.

Date and time values in email messages include a time zone value, so that they can be specified uniquely.  When they are displayed in Gmail, they are adjusted to your local time by your browser's javascript interpreter.  The time zone used is determined by your browser, from the settings in your operating system.

To verify the time zone being used in your browser, open a new window and enter javascript:new%20Date() or javascript:alert(new%20Date()) in the location bar (use the latter for Safari).  For all browsers, except IE, the result will be in a standard form:


     Thu Sep 18 2008 11:42:20 GMT-0700 (Pacific Daylight Time)


The important part for getting the right time on your messages is the time zone offset (GMT-0700).  It shows the adjustment that must be applied, in hours and minutes, to UTC (née GMT) to get the local time.  All times in messages are adjusted to this offset.  If it is not correct, adjust the time zone in your operating system, restart your browser and try again.


For US time zones, IE uses a non-standard display:

   Thu Sep 18 11:42:20 PDT 2008

The time zone offset is implicit in the abbreviation (PDT is GMT-0700), but you can remove any ambiguity by using javascript:new%20Date().getTimezoneOffset()/-60 to get the offset in hours.


Known problems:

  • The Chrome browser has a time zone bug for locations in the southern hemisphere, at least through version  Chrome's javascript is adding an extra hour to the offset, and therefore, to all displayed times.


  • This discussion does not apply if you are using basic HTML view.  If the times are incorrect in basic HTML, you must correct it by setting the time zone in your Google account.  (https://www.google.com/accounts/EditUserInfo)