1
votes

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

2

2 Answers

2
votes

In your model you define Ext.data.Field. Have a look in the API docs, Ext.data.Field has no configuration called format, but dateFormat.

Try this

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

and you just need mapping, if your data from the backend has a different name as you want to use in the model.

BTW: since ExtJS 4.1.3 there also are two new config items: dateReadFormat and dateWriteFormat to define different format for the reader and the writer. But if you define dateFormat this will be the same for both.

1
votes

on the form field you need the extra property submitFormat:

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