Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Date in Extjs

Tags:

date

extjs

I have a Date string of following format:

'31-OCT-2013'

How do I convert this into Date of following format using Extjs 4:

'08/31/2013'

I am using IE8.

like image 601
user204069 Avatar asked Nov 06 '13 01:11

user204069


2 Answers

If you have string "31-OCT-2013", you need to:

Convert it into date object

var myDate = Ext.Date.parse("31-OCT-2013", 'd-M-Y');

Format it to as you want

Ext.Date.format(myDate, 'm/d/Y');
like image 63
Sivakumar Avatar answered Nov 14 '22 22:11

Sivakumar


Try something like this:

If your day representation would be 2 digit with leading zero, then apply this

var date = Ext.Date.parse("31-OCT-2013", 'd-M-Y');
console.log(Ext.Date.format(date, 'm/d/Y'));

But if your day representation would be without a leading zero, then apply this

var date = Ext.Date.parse("31-OCT-2013", 'j-M-Y');
console.log(Ext.Date.format(date, 'm/d/Y'));

Check the docs for Ext.Date

like image 38
fujy Avatar answered Nov 14 '22 23:11

fujy