Date format with adobe flex

actionscript-3apache-flexflex3

I have a date and I would like to format the date like that:
YYYYMMDD HHMMSS
so for today it's
20100304 173000

But when I'm doing this:

var todayStr:String = today.getFullYear()+today.getMonth()+today.getDay()+today.getHours()+today.getMinutes();

the problem is for March getMonth() sent "3" and I would like "03". There is the same problem with the day.

How I can do?

Thanks.

Best Answer

You can use a DateFormatter. Have a look at this : Dateformatter @ adobe

var formatter : DateFormatter;
formatter = new DateFormatter();
formatter.formatString = "YYYYMMDD HHNNSS";
formatter.format(dateInstance);

beware of the 'N' used for the minutes

Related Topic