Reputation: 4135
I have a requirement. I have a date format as yyyy/mm/dd
and I want to convert this format to mm/dd/yyyy in action script.
I had tried to parse to this format, it is not working. Can any one of you please help me?
Upvotes: 0
Views: 1315
Reputation: 1871
If we're opting for string manipulation, why not this:
'2010/05/14'.replace(/(\d{4})\/(\d{2})\/(\d{2})/, '$2/$3/$1')
Upvotes: 0
Reputation: 11912
var s:String = "2012/03/05";
var dateParts:Array = s.split('/'); //['2012', '03', '05']
//take off the first element and add it back at the end
dateParts.push(dateParts.shift()); //['03', '05', '2012']
s = dateParts.join('/'); //'03/05/2012'
trace(s);
Upvotes: 3