getMonth (Date.getMonth method)

public getMonth() : Number

Returns the month (0 for January, 1 for February, and so on) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Availability: ActionScript 1.0; Flash Player 5

Returns

Number - An integer.

Example

The following example uses the constructor to create a Date object based on the current time and uses the getMonth() method to return the month value from that object:

var my_date:Date = new Date();
trace(my_date.getMonth());

The following example uses the constructor to create a Date object based on the current time and uses the getMonth() method to display the current month as a numeric value, and display the name of the month.

var my_date:Date = new Date();
trace(my_date.getMonth());
trace(getMonthAsString(my_date.getMonth()));
function getMonthAsString(month:Number):String {
    var monthNames_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    return monthNames_array[month];
}

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001588.html