Return to Snippet

Revision: 26599
at May 3, 2010 14:37 by jjdowding


Initial Code
//trace(new Date("2010/05/03T14:14Z")); ----> this will error 'invalid date'

var isoDate = "2010-05-03T14:14Z";

//this will remove the T and Z
var date = isoDate.replace(/[A-Z]/gi," ");

//this will replace the hypens with forward slashes
date = date.replace(/\-/gi, "/");

//this casts the string to date and creates the correct date object
trace(new Date(date));

Initial URL

                                

Initial Description
probably not the best way but easy enough

Initial Title
iso 8601 to as3 date object

Initial Tags
date

Initial Language
ActionScript 3