PDA

View Full Version : Date and time format



pra123@
22 May 2013, 8:03 AM
Hi all,
I have a grid with one date column.
I am geting date and time from server in ISO format.
like. "2012-05-08T05:32:36.703"
I am showing this data to date column.
i have set format for date column "d-M-Y h:i:S A"
But its showing in date column like- "08-May-2012 11:02:36 AM"
here we ca see time is not showing correctly. it adding 5:30 hours.
Can some tell why and how its adding these extra hours?

Dev@QLP
22 May 2013, 8:18 AM
What do you have the Ext.data.Model Field type set as? String or Date? Do you have a dateformat defined there as well?

friend
22 May 2013, 8:58 AM
I think Dev@QLP is on the right track. Your model should look something like this:



Ext.define('YourApp.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'userName', type: 'string'},
{name: 'someDate', type: 'date', dateFormat: 'c'},
}


And a grid column renderer would look something like this:



columns = [
{header: 'Datetime', dataIndex: 'someDate', sortable: true, width: 90, renderer: Ext.util.Format.dateRenderer('d-m-Y h:i:s A')}
}

pra123@
22 May 2013, 10:28 PM
Hi Dev@QLP & friend,
Thanks a lot for your reply.
I was not setting any Field type or DateFormat to my Ext.data.Model.
From server, i am getting date like "2012-05-08T05:32:36.703" in my store.
i was setting only date format ("d-M-Y h:i:S A") for date column in grid panel.
Now i have type as 'date' and dateFormat as 'c' in my Model. then it showing correctly.
its working for me now.

Thanks again.