Reputation: 628
hello there's I want to convert 03-04-2017 12:00AM to 2017-12-01 12:00:00 how can I do it in Ext Js currently my code is:
this.ToDatePicker = Ext.create('Ext.form.field.Text', {
xtype: 'textfield',
name: 'name',
labelAlign: 'top',
fieldLabel: 'Date Time',
value: Ext.Date.format(new Date(), "d-m-Y h:iA"),
listeners: {
scope: this,
afterrender: function (c) {
c.getEl().on('click', function (e) {
console.log(e.target)
NewCssCal_DisableAfterToday(Ext.get(e.target).dom.id, 'ddmmyyyy', 'dropdown', true, 12)
});
}
}
});
this.ToCalenderIcon = new Ext.Container({
html: "<img class='calIcons' src='public/touchWorldCssJs/images/cal.gif'/>",
scope: this,
padding: '27 5 5 5',
listeners: {
scope: this,
afterrender: function (c) {
c.getEl().on('click', function (e) {
if (Ext.get(e.target).hasCls('calIcons')) {
console.log(Ext.get(e.target).dom.id);
NewCssCal_DisableAfterToday(me.ToDatePicker.inputEl.id, 'ddmmyyyy', 'dropdown', true, 12)
}
});
}
}
});
this.ToCalenderIcon after rendering this set date formate like 03-04-2017 12:00AM So I need to convert this to 2017-12-01 12:00:00
Upvotes: 0
Views: 262
Reputation: 2053
The AM/PM notion isn't supported by JavaScript natively as far as I could tell, so you'll have to do the parsing according to the specified format through Ext.Date.
In your toDatePicker, you explicitly format the date to be "d-m-Y h:iA". To get that back into a different format you need to first parse it (as JavaScript's native Date can't parse the resulting string):
Ext.Date.format(Ext.Date.parse("03-04-2017 12:00AM", "d-m-Y h:iA"), "d-m-Y h:i:s")
I hope that's what you were looking for. If you're instead interested how to make the 3rd of April look like the first of December, you should just write 1st of December in the first place.
Upvotes: 1