solarissf
solarissf

Reputation: 1277

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

Upvotes: 0

Views: 739

Answers (2)

Nishant Bajracharya
Nishant Bajracharya

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

Alexander
Alexander

Reputation: 20224

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

Upvotes: 1

Related Questions