Copy link to clipboard
Copied
I'm working with XML in AS3. I'm loading in some xml that has dates in a format like:
2011-1-12-10-00-a
I am converting those to actual Flash Date so I can compare them and use the methods of the Date class, etc. I would prefer to convert them once and then store them back in the XML node they came from.
Is it possible to store complex values like date or what have you in an XML?
yes, or more directly use:
var ms:int=date.getTime();
var newDate:Date = new Date(ms);
Copy link to clipboard
Copied
you can but not as a date object. you have to serialize your date object, save that to your xml and then unserialize your date object.
that may be less efficient than using a string to save to your xml and converting that back to ta date object.
Copy link to clipboard
Copied
Thanks.
Copy link to clipboard
Copied
Okay a follow up question.
If I store the number of milliseconds of the date using date.getValueOf(), is there an easy way to change those milliseconds back to a date object?
Copy link to clipboard
Copied
Never mind found it myself: date.setTime()
Copy link to clipboard
Copied
yes, or more directly use:
var ms:int=date.getTime();
var newDate:Date = new Date(ms);
Copy link to clipboard
Copied
Thanks. Strange that they seem to do the same thing.