0

In the EXTJS 3, if I have a string like 'Fri Jul 13 00:00:00 EDT 2012' , how can I get date string '07/13/2012' ? Does EXTJS have some API to handle this ?

Thanks

---- Update --- I found a way, like this

               if (Ext.isDate("Fri Jul 13 00:00:00 EDT 2012")) {
                    var date1 = new Date("Fri Jul 13 00:00:00 EDT 2012");
                    var start_str = date1.format('m/d/Y');
                }
TheWhiteRabbit
  • 15,480
  • 4
  • 33
  • 57
user595234
  • 6,007
  • 25
  • 77
  • 101

2 Answers2

0

Im not sure about ExtJS specifically but there's a very similar question asked here and the answer links to the documentation; it's worth checking that question out just for the example in the answer though!

In a pure Javascript implementation a regex may be the way to go. There's quite a few Regex Examples available and even a few Generators which can make your life easier if you aren't too confident with regex. Here's an example of the generated code from that site - jsFiddle link. (Thats not the cleanest way of doing a regex, when you use a generator it actually leaves quite a lot to be desired unfortunately. But it does work and give a decent starting point!)

Upon closer inspection of the string, I notice it uses text to signify the month. This could be worked around via the use of an enum.

As far as ExtJS goes - there's a pretty good blog post here about some of the date format options. But I think the documentation linked at the top of the answer is the best place to be looking.

Community
  • 1
  • 1
Fergus In London
  • 1,203
  • 8
  • 19
0

JavaScript's Date object should provide everything you need here:

var d = new Date('Fri Jul 13 00:00:00 EDT 2012');
var out = (d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear()
JohnnyHK
  • 305,182
  • 66
  • 621
  • 471