Return to Snippet

Revision: 7612
at July 31, 2008 12:23 by Winkyboy


Initial Code
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);
}

Initial URL

                                

Initial Description
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.

Initial Title
AS2 convert string to date

Initial Tags
date, convert

Initial Language
ActionScript