var d:Date=new Date(); trace(d.month);
The output window will display a number for the month beginning with 0 for January, 1 for February, 2 for March, etc.
If we want to display the name of the month we must use an array, then display the name of the month from the array:
var d:Date=new Date();
var hour:int=d.hours;
var greeting:String;
if(hour<12) greeting="Good Morning!";
else if (hour<18) greeting="Good Afternoon!";
else greeting="Good Evening!";
lblGreeting.text=greeting;
var day: Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var dayNum:int=d.getDay();
lblDay.text="Today is "+day[dayNum];
var month: Array = new Array("January", "February", "March", "April", "May", "June","July", "August","September", "October", "November", "December");
var monthNum:int=d.getMonth();
lblDate.text=month[monthNum]+ " "+d.date+", "+d.getFullYear();
Download the movie
You could also do this using a timer.
INDEX, Introduction to the Date Class, The Date, A Digital Clock, An Analog Clock (with hands)
Next lesson: Examples