Search code examples
extjsdatefield

extjs6 datefield - converting to short date string


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')

screenshot below enter image description here


Solution

  • As per the docs,

    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')