/ Published in: ActionScript
This function takes a string containing a date in "mm/dd/yyyy" or "m/d/yyyy" format and converts it to a date object in AS2.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function convertMyDate(strToCheck):Date { var uryear:String; var urmonth:String; var urday:String; var newDate:Date; uryear = strToCheck; uryear = uryear.substr(uryear.length - 4, 4); urmonth = strToCheck; urmonth = urmonth.substr(0, urmonth.indexOf("/")); urday = strToCheck; urday = urday.substr(0, urday.length - 5); urday = urday.substr(2, urday.indexOf("/")+1); newDate = new Date(Number(uryear),Number(urmonth)-1,Number(urday)); return(newDate); }