public function compare (date1 : Date, date2 : Date) : Number
{
var date1Timestamp : Number = date1.getTime ();
var date2Timestamp : Number = date2.getTime ();
var result : Number = -1;
if (date1Timestamp == date2Timestamp)
{
result = 0;
}
else if (date1Timestamp > date2Timestamp)
{
result = 1;
}
return result;
}
public function compare (date1 : Date, date2 : Date) : Number { var date1Timestamp : Number = date1.getTime (); var date2Timestamp : Number = date2.getTime (); var result : Number = -1; if (date1Timestamp == date2Timestamp) { result = 0; } else if (date1Timestamp > date2Timestamp) { result = 1; } return result; } |
Error Cannot convert XMLList@5967b21 to Date
To convert XMLList date to date, first convert it to String then the date string into Milliseconds using the Date.parse method. Then you can convert the seconds to Date object
Ex: var dateString:String = xmlDateValue.toString();
var dateInMilliseconds:Number = Date.parse(dateString);
//date format "Wed May 4 15:30:17 GMT-0700 2011"
var curDate:Date = Date(dateInMilliseconds);
Ex: var dateString:String = xmlDateValue.toString();
var dateInMilliseconds:Number = Date.parse(dateString);
//date format "Wed May 4 15:30:17 GMT-0700 2011"
var curDate:Date = Date(dateInMilliseconds);
No comments:
Post a Comment