PDA

View Full Version : dateFormat with timezone



KimH
2 Mar 2007, 5:57 AM
If I create JSON data on server in this format:

2007-03-02T15:00:00+01:00
and have my data record specified with type 'date' and dateFormat:

Y-m-d\\TH:i:sO
then the output is blank.

If I create JSON data on server in this format:

2007-03-02T15:00:00
and have my data record specified with type 'date' and dateFormat:

Y-m-d\\TH:i:s
then the output is shown but in wrong timezone.

JeffHowden
2 Mar 2007, 12:05 PM
Eliminating the complexity of the grid and default renderers, can you confirm this behavior when using the Extified Date object by itself?

KimH
2 Mar 2007, 2:00 PM
var date = Date.parseDate('2007-03-02T15:00:00+01:00', 'Y-m-d\\TH:i:sO');
Returns null


var date = Date.parseDate('2007-03-02 15:00:00+01:00', 'Y-m-d H:i:sO');
Returns null


var date = Date.parseDate('2007-03-02 15:00:00', 'Y-m-d H:i:s');
alert(date);
Returns "Fri Mar 2 15:00:00 UTC+0100 2007"


var date = Date.parseDate('2007-03-02 15:00:00', 'Y-m-d H:i:s');
alert(date.getGMTOffset());
Returns "+-100"

Doesn't it look weird?

jack.slocum
3 Mar 2007, 2:04 PM
var date = Date.parseDate('2007-03-02T15:00:00+01:00', 'Y-m-d\\TH:i:sO');

You have a colon in your timezone info which is not supported. It should be:

2007-03-02T15:00:00+0100

I can look at adding support for it (since I think that's how ISO does it?). Would it be easier for you to remove the colon?

KimH
3 Mar 2007, 2:30 PM
Sure I can remove the colon; I just read some ISO 8601 docs and what I did with the colon is the 'extended' format, where the 'basic' format does not have a colon. This doesn't bother me for now...

However...
It now outputs the dates... except that if my server-generated date/time is:

"2006-09-09T22:56:08+0100"

then it says

"Sat Sep 09 2006 22:56:08 GMT+0200"

in the grid. Notice the timezone!

jack.slocum
3 Mar 2007, 2:33 PM
I will do some digging.

KimH
3 Mar 2007, 4:40 PM
Jack I just tried to output this date/time on my server to two different fields:

"2006-09-09T22:56:08+0100"

and when renderen in the columns it shows:

"Sat Sep 09 2006 22:56:08 GMT+0200"
"Sat Sep 09 2006 22:56:08 GMT+0100"

in the grid. Notice the timezone! This is the case for all records down the grid... +0200 in the first column and +0100 in the second.