PDA

View Full Version : How to parse this date data: 2013-09-04T08:49:15-07:00



glafrance
4 Sep 2013, 7:57 AM
I'm trying to parse this date data: 2013-09-04T08:49:15-07:00

Here is my model:


fields: [
{ name: 'loginDate', type: 'date', dateFormat: 'time' }
]

Here is the grid column:


me.columns = [{
xtype: 'datecolumn',
text: LoginHistoryResources.getResource('xLoginHistory_TimestampColHeader'),
renderer: function (value) {
return Ext.Date.parse(value, "Y-m-dTH:i:sP");
},
flex: 5,
dataIndex: 'loginDate'
}];

And here is how I handle the data in the result handler:


var store = Ext.getStore('Module.loginHistory.store.LoginHistory');
store.loadRawData(response);

if (me.getLoginHistoryGrid()) {
var table = me.getLoginHistoryGrid();
table.store = store;
table.setLoading(false);
}



Is
Y-m-dTH:i:sP the problem? If so, what should I do?

glafrance
4 Sep 2013, 8:03 AM
This fixed it:


{ name: 'loginDate', type: 'string' },

julio.batista
5 Sep 2013, 3:18 AM
Take a look at http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Date for date formats

Frith
5 Sep 2013, 6:04 AM
You may have issues with different browsers parsing the date.

The 'T' in your dateFormat is being interpreted as timezone. As per Julio's post, check out the date documentation. I believe you need 'c' for ISO standard:


c ISO 8601 date Notes: Examples: 1) If unspecified, the month / day defaults to the current month / day, 1991 or the time defaults to midnight, while the timezone defaults to the 1992-10 or browser's timezone. If a time is specified, it must include both hours 1993-09-20 or and minutes. The "T" delimiter, seconds, milliseconds and timezone 1994-08-19T16:20+01:00 or are optional. 1995-07-18T17:21:28-02:00 or 2) The decimal fraction of a second, if specified, must contain at 1996-06-17T18:22:29.98765+03:00 or least 1 digit (there is no limit to the maximum number 1997-05-16T19:23:30,12345-0400 or of digits allowed), and may be delimited by either a '.' or a ',' 1998-04-15T20:24:31.2468Z or Refer to the examples on the right for the various levels of 1999-03-14T20:24:32Z or date-time granularity which are supported, or see 2000-02-13T21:25:33

shashankbs086
6 Sep 2013, 7:22 AM
The Date shown is in ISO 8601 format.

You can do like this in your renderer function

Ext.Date.parse(value, 'c')

This gives you the date in the following format


Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)