PDA

View Full Version : Date with incorrect timezone



Tim Siney
18 Jan 2011, 5:14 AM
I have a problem with the Ext Date class seemingly returning the wrong timezone for a parsed date. Using the code below I create a date object for the 24th May, 1966 15:46 BST:



date = "1966-05-24T15:46:01+0100";
var pDate = Date.parseDate(date, "Y-m-d\\TH:i:sO", false);


I then call this:


console.log(pDate.getGMTOffset());

I am expecting to get the offset associated with the orignal date back (which is GMT + 1), but instead I get the local timezone of the browser instead. If the browser is set to a timezone far enough ahead GMT, the day portion of the date will also be rolled over (so the date will now appear as 25th May, 1966).

How do I get around this and get Ext to recognise the correct timezone of the parsed date rather than the local browser timezone?

If this is not possible, can Ext be forced to use GMT rather than trying to interpret timezones?

Foster
18 Jan 2011, 5:32 AM
I used this in my app which worked nicely

http://www.sencha.com/forum/showthread.php?57620-Extention-to-Ext.Date-for-UTC-conversion

Tim Siney
18 Jan 2011, 7:56 AM
Thanks, some useful ideas in that thread.