Tyomik_mnemonic
Tyomik_mnemonic

Reputation: 956

extjs. How to change dataformat for Ext.field.DatePicker

my post requires is fallen, cause DB need yyyy-mm-dd format. But datepickerfield has mm-dd-yyyy. format config doesn't work:

..,{

        xtype: 'datepickerfield',
        destroyPickerOnHide: true,
        format: 'Y-m-d', 
        value: new Date(),
        label: 'Start date',
        name: 'use_start'
    },..

How to change dataformat?

Upvotes: 0

Views: 1014

Answers (2)

Tyomik_mnemonic
Tyomik_mnemonic

Reputation: 956

Well after using of Enzo's suggest data format in Ext JS had corrected. But request stays failure. It was fixed by changing DataField model Django to DataTimeField. Check your backends too, if you face with problem like that.

Upvotes: 0

Enzo B.
Enzo B.

Reputation: 2371

The first solution is to convert you'r date before sending it like this :

Ext.Date.format(DATE_VAR, DATE_FORMAT);

List of format : https://docs.sencha.com/extjs/6.6.0/modern/Ext.Date.html

Another solution is to override the default date like this into you'r application constructor :

Ext.apply(Ext.util.Format, {
    defaultDateFormat: DATE_FORMAT
})

Upvotes: 1

Related Questions