Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS : Submit Date in Separate Format

Tags:

extjs

extjs4

I'm using ExtJS v4.0.

Maintaining date format between client and server side is really confusing.

Users want their own input formats, but the server usually requires the submission to be one standard format.

It should be a built in implementation in ExtJS but it's not.

I have read some solutions regarding to this issue but they only try to solve DateField formatting (by creating special DateField plugin or extending SubmitAction).

I'm looking for a global solution to format all dates which can be submitted (grid/store writer, form/datefield, etc).

So, dates may have custom display format according to locale but they will be submitted in one standard format (e.g. yyyy-mm-dd).

Any suggestion for this problem?

Thank you very much.

like image 563
Fitrah M Avatar asked Apr 12 '26 01:04

Fitrah M


1 Answers

This was the only working answer that I found from documentation using version 4.2.1

    Ext.Date.patterns = {
    ISO8601Long:"Y-m-d H:i:s",
    ISO8601Short:"Y-m-d",
    ShortDate: "n/j/Y",
    LongDate: "l, F d, Y",
    FullDateTime: "l, F d, Y g:i:s A",
    MonthDay: "F d",
    ShortTime: "g:i A",
    LongTime: "g:i:s A",
    SortableDateTime: "Y-m-d\\TH:i:s",
    UniversalSortableDateTime: "Y-m-d H:i:sO",
    YearMonth: "F, Y"
};


//allow max date as today
Ext.override(Ext.form.DateField, {
    submitFormat:Ext.Date.patterns.ISO8601Short
});
like image 128
Mario C Avatar answered Apr 14 '26 12:04

Mario C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!