Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date compare from XML

Status
Not open for further replies.

dallasweb

Programmer
Jan 4, 2001
45
0
0
US
Hello,

Is the an obvious way to do this....cuz I'm banging my head on the wall here.

I have a XML doc that has a date-time value. I want to compare that date against now. If XML date is in the future, proceed to next frame kinda thing. What format does a date-time have to be in order to convert it to a date object in Flash?

When I do:
myDate = new Date();
I get something like this: Thu Mar 4 21:40:29 GMT-0500 2004

How can I compare that to my time stamp coming from XML? Cuz when I try to convert a string to a Date I get "Invalid Date"

I tried this but no luck:

From the XML doc:
2004,04,28,12,47,52,00

AS code:
alertDate = alert_xml.firstChild.childNodes[0].firstChild.childNodes[0];
tempS = new String(alertDate);
tempD = new Date(tempS);

returns "Invalid Date"


BUT.....This works:
tempD = new Date(2004,04,28,12,47,52,00);
returns: Fri May 28 12:47:52 GMT-0400 2004

How come I can't (haven't figure'd out yet) use my XML value and convert it to a date?

Thanks and bows in advance!

Dman

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top