Flash Lite 2.x and 3.0 ActionScript Language Reference

setYear (Date.setYear method)

public setYear(year:Number) : Number

Sets the year for the specified Date object in local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.

Parameters

year:Number - A number that represents the year. If year is an integer between 0 and 99, setYear sets the year at 1900 + year; otherwise, the year is the value of the year parameter.

Returns

Number - An integer.

Example

The following example creates a new Date object with the date set to May 25, 2004, uses setYear() to change the year to 1999, and changes the year to 2003:

var my_date:Date = new Date(2004,4,25);
trace(my_date.getYear()); // output: 104
trace(my_date.getFullYear()); // output: 2004
my_date.setYear(99);
trace(my_date.getYear()); // output: 99
trace(my_date.getFullYear()); // output: 1999
my_date.setYear(2003);
trace(my_date.getYear()); // output: 103
trace(my_date.getFullYear()); // output: 2003