• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date nodes in XML

LEGEND ,
Apr 05, 2012 Apr 05, 2012

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?

TOPICS
ActionScript

Views

945

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 06, 2012 Apr 06, 2012

yes, or more directly use:

var ms:int=date.getTime();

var newDate:Date = new Date(ms);

Votes

Translate

Translate
Community Expert ,
Apr 05, 2012 Apr 05, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2012 Apr 06, 2012

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

Never mind found it myself: date.setTime()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2012 Apr 06, 2012

Copy link to clipboard

Copied

yes, or more directly use:

var ms:int=date.getTime();

var newDate:Date = new Date(ms);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2012 Apr 09, 2012

Copy link to clipboard

Copied

LATEST

Thanks. Strange that they seem to do the same thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines