Reputation: 1277
In my extjs6 project I have a datefield. When I getvalue it comes back as '2017-07-26T00:00:00'. How can I convert this to 07-26-2017?
I am trying the below which is coming back blank. var newVal = Ext.Date.format(value, 'm-d-Y')
Upvotes: 0
Views: 739
Reputation: 361
You don't need to use
Ext.Date.format and Ext.Date.parse functions
just change the xtype and format property to your gridcolumn
xtype: 'datecolumn',
format: 'm-d-Y'
Example code set grid column property
columns: [
{
text: 'Date',
dataIndex: 'date',
xtype: 'datecolumn',
format:'m-d-Y'
}
],
This will give the output as in '07-26-2017' format.. No need to use renderer as well hope ull try this
Upvotes: 1
Reputation: 20224
As per the docs,
Ext.Date.parse
makes a javascript date from a string.Ext.Date.format
makes a string from a javascript date.Since you need to convert a string to a string, you have to combine the two:
Ext.Date.format(Ext.Date.parse('2017-07-26T00:00:00','c'), 'm-d-Y')
Upvotes: 1