Android phones and timezones - TimezoneOffset returns old info

This forum contains topics that were moved from Get Satisfaction
Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Android phones and timezones - TimezoneOffset returns old info

Post by Ole Henrik Oftedal »


This is not a question. Just to inform others working with timezones. This is only a problem on som Android phones and not on Iphones (IOS).

I you i.e. return from East Africa to Europe (CET) you can get this situation if you do not reboot your phone.

This code:
function GetDeviceTimezoneOffset() {
var d = new Date();
var n = d.getTimezoneOffset() * -1;
return "" + n;
ERROR: Returns 240 minutes instead of 60.

This code:
function checkDatePattern() {
function (date) { alert('Timezone: ' + date.timezone + '\n'); },
function () { alert('Error getting timezone\n'); },
{ formatLength: 'short', selector: 'date and time' }

Correct: Returns "Timezone: GMT+01:00"

When I get some spare time I will try to extract the offset in minutes from Cordova Globalization project instead as this is correct. (dst_offset property in Cordova module is not supported, and always returns zero.)

Best regards

Ole Henrik Oftedal
Timeflex Systemer AS