javascriptextjsextjs6extjs6-modern

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?


Solution

  • 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
    })