Reputation: 2444
I want to be able to parse my date based on the dd-MM-yyyy in flash however I can't quite get it.
Here is my code:
var arrivalDate = String(arrivalDateDay.text)+String(arrivalDateMonth.text)+String(arrivalDateYear.text);
trace(arrivalDate);
arrivalDate = Date.parse(Number(arrivalDate));
trace(arrivalDate);
The first trace will show the date like "ddMMyyyy", but after the parse I simply get NaN. I also tried trace(Number(arrivalDate));]
The reason why I want to be able to parse the date is so I can calculate the number of days apart from two dates.
Thanks, Peter
Upvotes: 3
Views: 4159
Reputation: 13532
You need to pass a supported format to Date.parse
From here :
Other supported formats include the following (you can include partial representations of these formats; that is, just the month, day, and year):
MM/DD/YYYY HH:MM:SS TZD
HH:MM:SS TZD Day Mon/DD/YYYY
Mon DD YYYY HH:MM:SS TZD
Day Mon DD HH:MM:SS TZD YYYY
Day DD Mon HH:MM:SS TZD YYYY
Mon/DD/YYYY HH:MM:SS TZD
YYYY/MM/DD HH:MM:SS TZD
As the documentation states you can leave out the hour minute second parts and just use day month year. Right now you are passing in the day, month and year with no spaces between.
Upvotes: 6