PDA

View Full Version : date format with extjs 4.1 issue



Anthony.Hall
27 Apr 2012, 3:32 AM
In my model (Ext.data.Model) i have the following property


{
mapping:'Created',
name:'Created',
type: 'date',
format:'d/m/Y'
},



On my form i have the following field


{
xtype:'datefield',
name:'Created',
fieldLabel:' Date',
format:'d/m/Y',
width: 350
},



If i select the following date in the picker "01/04/2012" ( i'm in the UK, 1st April 2012)I get the following in firebug json post "2012-01-04T00:00:00" ( 4th Jan 2012 )How can i ensure the correct regions are coming through

Moinsen
27 Apr 2012, 4:26 AM
Hi Anthony,

try the altFormats config. This should work.



xtype: 'datefield',
format: 'd.m.Y',
altFormats: "Y-m-d H:i:s",
fieldLabel: 'Ablaufdatum',
name: 'expirationDate',
emptyText: '1.1.1900',
submitEmptyText: false,
allowBlank: true


Regards

Anthony.Hall
27 Apr 2012, 7:57 AM
hmm, just tried to add "
altFormats" but it seems to still add the dates in US format. Am i missing something. Maybe i have to set some locale setting?

friend
27 Apr 2012, 10:30 AM
I think you're declaring the date format attribute incorrectly in your model. It should look like this:



{
mapping:'Created',
name:'Created',
type: 'date',
dateFormat:'d/m/Y'
},