I am using the following code:
var date="May-02-2012";
var startDate = date;
var tmp = startDate.split('-');
tmp.splice(1, 0, ',');
var convertedStartDate = new Date(tmp.join(' '));
var month = convertedStartDate.getMonth() + 1
var day = convertedStartDate.getDate();
var year = convertedStartDate.getFullYear();
var shortStartDate = ('0' + day).slice(-2) + "-" + ('0' + month).slice(-2) + "-" + ('0' + year).slice(-2);
return(shortStartDate);
The code above allows my to convert May-02-2012 to 02-05-12
however, I now need to convert it from 02-05-12 back to May-02-2012
But I can’t work it out..
No too hard provided the format is as you specified. The following doesn’t do any testing so if the format is wrong, it might to awry. But so will any function if you give it the wrong format.