Posted By

jjdowding on 05/03/10


Tagged

date as3 iso8601


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


iso 8601 to as3 date object


 / Published in: ActionScript 3
 

probably not the best way but easy enough

  1. //trace(new Date("2010/05/03T14:14Z")); ----> this will error 'invalid date'
  2.  
  3. var isoDate = "2010-05-03T14:14Z";
  4.  
  5. //this will remove the T and Z
  6. var date = isoDate.replace(/[A-Z]/gi," ");
  7.  
  8. //this will replace the hypens with forward slashes
  9. date = date.replace(/\-/gi, "/");
  10.  
  11. //this casts the string to date and creates the correct date object
  12. trace(new Date(date));

Report this snippet  

You need to login to post a comment.