ExtJS Dates and Timeouts

I have a problem with the Ext Date class, apparently returning the wrong time zone for the parsed date. Using the following code, I create a date object for May 24, 1966 15:46 BST:

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

Then I call this:

console.log(pDate.getGMTOffset());

I expect to get the offset associated with the orignal date (GMT + 1), but instead I get the local time zone of the browser. If the browser is set to a time zone far enough from GMT, the daytime part of the date will also be upside down (so that the date will now appear on May 25, 1966).

Does anyone know how to get around this and make Ext recognize the correct time point of the syntax date, not the local time zone of the browser?

If this is not possible, can Ext force GMT instead of trying to interpret time intervals?

+5
source share
3 answers

I checked the implementation of parseDate () in the ExtJS source code and the date documentation in basic JavaScript , the Date () constructor used by ExtJS does not support time zone information. JavaScript Date objects represent a UTC value, without a time zone. During parsing in ExtJS source code, the time zone is lost, and the corresponding offset in minutes / seconds is added to the date.

Then I checked the source code of getGMTOffset () defined by ExtJS : it builds a timezone string using the specific getTimezoneOffset () function in JavaScript.

getTimezoneOffset():

- (GMT). .

, , , , .

, ,

new Date(2010,1,20).getTimezoneOffset()
// -60
new Date(2010,9,20).getTimezoneOffset()
// -120

: Date ExtJS, Date.parse() Mozilla Doc Center :

, , , , 1 1970 00:00:00 UTC .

+6

My two cents, because I can’t set all my time until 12:00, as Tim did. I posted on the sencha forum

0
source

All Articles