Reputation: 305
I have a form, developed using ExtJs, which contains the DateField, on form submission, the date gets submitted in seconds rather than the format I defined.
My problem is: I want to submit the date in the same format like its defined in the format property.
Below is the DateField code snippet:
Ext.create('Ext.form.field.Date',{
fieldLabel: 'Date1',
name: 'date1',
id: 'date1',
allowBlank: true,
format: 'Y-m-d',
submitFormat: 'Y-m-d',
})
I would appreciate if someone can help me to figure it out.
Thank you in advance.
Upvotes: 0
Views: 214
Reputation: 20224
Form.getRecord
returns to you a model instance, as per the docs.
A model instance has fields which are have defined value types, as per the docs. If your field is defined as an int field, and not a date, you get the seconds. If you define it as a date field, you get the javascript date.
Depending on how you actually send that model to the server, you will have to manually format the date from the model into the desired string using Ext.Date.format
, or you may be able to use the dateWriteFormat
config of the field, as per the docs.
Upvotes: 0
Reputation: 2423
In date fields format it leads Defaults to: "m/d/Y"
DateDoc. Your format must be valid according to Ext.Date#parse.Date Parse
To make your desire format you must have to use Ext.Date#parse.
dt = Ext.Date.parse("2006-01-15", "Y-m-d");
Refer the link for date parsing.
I created a fiddler for you. Please check Fiddle
Upvotes: 2