PackageTop Level
Classpublic class Date
InheritanceDate Inheritance Object

Player version: Flash Player 5

The Date class lets you retrieve date and time values relative to universal time (Greenwich mean time, now called universal time or UTC) or relative to the operating system on which Flash Player is running. The methods of the Date class are not static but apply only to the individual Date object specified when the method is called. The Date.UTC() method is an exception; it is a static method.

The Date class handles daylight saving time differently, depending on the operating system and Flash Player version. Flash Player 6 and later versions handle daylight saving time on the following operating systems in these ways:

Flash Player 5 handles daylight saving time on the following operating systems as follows:

To call the methods of the Date class, you must first create a Date object using the constructor for the Date class, described later in this section.



Public Methods
 Method
  
Date([yearOrTimevalue:Number], [month:Number], [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number])
Constructs a new Date object that holds the specified date and time.
  
Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time.
  
Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object according to local time.
  
Returns the full year (a four-digit number, such as 2000) of the specified Date object, according to local time.
  
Returns the hour (an integer from 0 to 23) of the specified Date object, according to local time.
  
Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to local time.
  
Returns the minutes (an integer from 0 to 59) of the specified Date object, according to local time.
  
Returns the month (0 for January, 1 for February, and so on) of the specified Date object, according to local time.
  
Returns the seconds (an integer from 0 to 59) of the specified Date object, according to local time.
  
Returns the number of milliseconds since midnight January 1, 1970, universal time, for the specified Date object.
  
Returns the difference, in minutes, between the computer's local time and universal time.
  
Returns the day of the month (an integer from 1 to 31) in the specified Date object, according to universal time.
  
Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object, according to universal time.
  
Returns the four-digit year of the specified Date object, according to universal time.
  
Returns the hour (an integer from 0 to 23) of the specified Date object, according to universal time.
  
Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to universal time.
  
Returns the minutes (an integer from 0 to 59) of the specified Date object, according to universal time.
  
Returns the month (0 [January] to 11 [December]) of the specified Date object, according to universal time.
  
Returns the seconds (an integer from 0 to 59) of the specified Date object, according to universal time.
  
Returns the year of this Date according to universal time (UTC).
  
Returns the year of the specified Date object, according to local time.
  
Sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds.
  
setFullYear(year:Number, [month:Number], [date:Number]):Number
Sets the year of the specified Date object, according to local time and returns the new time in milliseconds.
  
Sets the hours for the specified Date object according to local time and returns the new time in milliseconds.
  
Sets the milliseconds for the specified Date object according to local time and returns the new time in milliseconds.
  
Sets the minutes for a specified Date object according to local time and returns the new time in milliseconds.
  
setMonth(month:Number, [date:Number]):Number
Sets the month for the specified Date object in local time and returns the new time in milliseconds.
  
Sets the seconds for the specified Date object in local time and returns the new time in milliseconds.
  
setTime(millisecond:Number):Number
Sets the date for the specified Date object in milliseconds since midnight on January 1, 1970, and returns the new time in milliseconds.
  
Sets the date for the specified Date object in universal time and returns the new time in milliseconds.
  
setUTCFullYear(year:Number, [month:Number], [date:Number]):Number
Sets the year for the specified Date object (my_date) in universal time and returns the new time in milliseconds.
  
setUTCHours(hour:Number, [minute:Number], [second:Number], [millisecond:Number]):Number
Sets the hour for the specified Date object in universal time and returns the new time in milliseconds.
  
Sets the milliseconds for the specified Date object in universal time and returns the new time in milliseconds.
  
setUTCMinutes(minute:Number, [second:Number], [millisecond:Number]):Number
Sets the minute for the specified Date object in universal time and returns the new time in milliseconds.
  
setUTCMonth(month:Number, [date:Number]):Number
Sets the month, and optionally the day, for the specified Date object in universal time and returns the new time in milliseconds.
  
setUTCSeconds(second:Number, [millisecond:Number]):Number
Sets the seconds for the specified Date object in universal time and returns the new time in milliseconds.
  
Sets the year for the specified Date object in local time and returns the new time in milliseconds.
  
Returns a string value for the specified date object in a readable format.
  
UTC(year:Number, month:Number, [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]):Number
[static]Returns the number of milliseconds between midnight on January 1, 1970, universal time, and the time specified in the parameters.
  
Returns the number of milliseconds since midnight January 1, 1970, universal time, for this Date.
 Methods inherited from class Object
 addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch
Constructor detail
Date()constructor
public function Date([yearOrTimevalue:Number], [month:Number], [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number])

Player version: Flash Player 5

Constructs a new Date object that holds the specified date and time.

The Date() constructor takes up to seven parameters (year, month, ..., millisecond) to specify a date and time to the millisecond. Alternatively, you can pass a single value to the Date() constructor that indicates a time value based on the number of milliseconds since January 1, 1970 0:00:000 GMT. Or you can specify no parameters, and the Date() date object is assigned the current date and time.

For example, this code shows several different ways to create a Date object:

var d1:Date = new Date(); 
var d3:Date = new Date(2000, 0, 1);
var d4:Date = new Date(65, 2, 6, 9, 30, 15, 0);
var d5:Date = new Date(-14159025000);

In the first line of code, a Date object is set to the time when the assignment statement is run.

In the second line, a Date object is created with year, month, and date parameters passed to it, resulting in the time 0:00:00 GMT January 1, 2000.

In the third line, a Date object is created with year, month, and date parameters passed to it, resulting in the time 09:30:15 GMT (+ 0 milliseconds) March 6, 1965. Note that since the year parameter is specified as a two-digit integer, it is interpreted as 1965.

In the fourth line, only one parameter is passed, which is a time value representing the number of milliseconds before or after 0:00:00 GMT January 1, 1970; since the value is negative, it represents a time before 0:00:00 GMT January 1, 1970, and in this case the time is 02:56:15 GMT July, 21 1969.

Parameters
yearOrTimevalue:Number [optional] — If other parameters are specified, this number represents a year (such as 1965); otherwise, it represents a time value. If the number represents a year, a value of 0 to 99 indicates 1900 through 1999; otherwise all four digits of the year must be specified. If the number represents a time value (no other parameters are specified), it is the number of milliseconds before or after 0:00:00 GMT January 1, 1970; a negative values represents a time before 0:00:00 GMT January 1, 1970, and a positive value represents a time after.
 
month:Number [optional] — An integer from 0 (January) to 11 (December).
 
date:Number [optional] — An integer from 1 to 31.
 
hour:Number [optional] — An integer from 0 (midnight) to 23 (11 p.m.).
 
minute:Number [optional] — An integer from 0 to 59.
 
second:Number [optional] — An integer from 0 to 59.
 
millisecond:Number [optional] — An integer from 0 to 999 of milliseconds.

See also


Example
The following example retrieves the current date and time:
var now_date:Date = new Date();

The following example creates a new Date object for Mary's birthday, August 12, 1974 (because the month parameter is zero-based, the example uses 7 for the month, not 8):

var maryBirthday:Date = new Date (74, 7, 12); 

The following example creates a new Date object and concatenates the returned values of Date.getMonth(), Date.getDate(), and Date.getFullYear():

var today_date:Date = new Date();
var date_str:String = ((today_date.getMonth()+1)+"/"+today_date.getDate()+"/"+today_date.getFullYear());
trace(date_str); // displays current date in United States date format

Method detail
getDate()method
public function getDate():Number

Player version: Flash Player 5

Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and concatenates the returned values of Date.getMonth(), Date.getDate(), and Date.getFullYear():
var today_date:Date = new Date();
var date_str:String = (today_date.getDate()+"/"+(today_date.getMonth()+1)+"/"+today_date.getFullYear());
trace(date_str); // displays current date in United States date format

getDay()method 
public function getDay():Number

Player version: Flash Player 5

Returns the day of the week (0 for Sunday, 1 for Monday, 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.

Returns
Number — An integer representing the day of the week.

Example
The following example creates a new Date object and uses getDay() to determine the current day of the week:
var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var today_date:Date = new Date();
var day_str:String = dayOfWeek_array[today_date.getDay()];
trace("Today is "+day_str);

getFullYear()method 
public function getFullYear():Number

Player version: Flash Player 5

Returns the full year (a four-digit number, such as 2000) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer representing the year.

Example
The following example uses the constructor to create a Date object. The trace statement shows the value returned by the getFullYear() method.

The following example uses the constructor to create a Date object and send the value returned by the getFullYear() method to the log file:

var my_date:Date = new Date();
trace(my_date.getYear()); // displays 104
trace(my_date.getFullYear()); // displays current year

getHours()method 
public function getHours():Number

Player version: Flash Player 5

Returns the hour (an integer from 0 to 23) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer.

Example
The following example uses the constructor to create a Date object based on the current time and uses the getHours() method to display hour values from that object:
var my_date:Date = new Date();
trace(my_date.getHours());

var my_date:Date = new Date();
var hourObj:Object = getHoursAmPm(my_date.getHours());
trace(hourObj.hours);
trace(hourObj.ampm);

function getHoursAmPm(hour24:Number):Object {
    var returnObj:Object = new Object();
    returnObj.ampm = (hour24<12) ? "AM" : "PM";
    var hour12:Number = hour24%12;
    if (hour12 == 0) {
    hour12 = 12;
    }
    returnObj.hours = hour12;
    return returnObj;
}

getMilliseconds()method 
public function getMilliseconds():Number

Player version: Flash Player 5

Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer.

Example
The following example uses the constructor to create a Date object based on the current time and uses the getMilliseconds() method to return the milliseconds value from that object:
var my_date:Date = new Date();
trace(my_date.getMilliseconds());

getMinutes()method 
public function getMinutes():Number

Player version: Flash Player 5

Returns the minutes (an integer from 0 to 59) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer.

Example
The following example uses the constructor to create a Date object based on the current time, and uses the getMinutes() method to return the minutes value from that object:
var my_date:Date = new Date();
trace(my_date.getMinutes());

getMonth()method 
public function getMonth():Number

Player version: Flash Player 5

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.

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];
}

getSeconds()method 
public function getSeconds():Number

Player version: Flash Player 5

Returns the seconds (an integer from 0 to 59) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running.

Returns
Number — An integer.

Example
The following example uses the constructor to create a Date object based on the current time and uses the getSeconds() method to return the seconds value from that object:
var my_date:Date = new Date();
trace(my_date.getSeconds());

getTime()method 
public function getTime():Number

Player version: Flash Player 5

Returns the number of milliseconds since midnight January 1, 1970, universal time, for the specified Date object. Use this method to represent a specific instant in time when comparing two or more Date objects.

Returns
Number — An integer.

Example
The following example uses the constructor to create a Date object based on the current time, and uses the getTime() method to return the number of milliseconds since midnight January 1, 1970:
var my_date:Date = new Date();
trace(my_date.getTime());

getTimezoneOffset()method 
public function getTimezoneOffset():Number

Player version: Flash Player 5

Returns the difference, in minutes, between the computer's local time and universal time.

Returns
Number — An integer.

Example
The following example returns the difference between the local daylight saving time for San Francisco and universal time. Daylight saving time is factored into the returned result only if the date defined in the Date object occurs during daylight saving time. The output in this example is 420 minutes and displays in the Output panel (7 hours * 60 minutes/hour = 420 minutes). The output in this example is 420 minutes and is written to the log file (7 hours * 60 minutes/hour = 420 minutes). This example is Pacific Daylight Time (PDT, GMT-0700). The result varies depending on location and time of year.
var my_date:Date = new Date();
trace(my_date.getTimezoneOffset());

getUTCDate()method 
public function getUTCDate():Number

Player version: Flash Player 5

Returns the day of the month (an integer from 1 to 31) in the specified Date object, according to universal time.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and uses Date.getUTCDate() and Date.getDate(). The value returned by Date.getUTCDate() can differ from the value returned by Date.getDate(), depending on the relationship between your local time zone and universal time.
var my_date:Date = new Date(2004,8,25);
trace(my_date.getUTCDate()); // output: 25

getUTCDay()method 
public function getUTCDay():Number

Player version: Flash Player 5

Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object, according to universal time.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and uses Date.getUTCDay() and Date.getDay(). The value returned by Date.getUTCDay() can differ from the value returned by Date.getDay(), depending on the relationship between your local time zone and universal time.
var today_date:Date = new Date();
trace(today_date.getDay()); // output will be based on local timezone
trace(today_date.getUTCDay()); // output will equal getDay() plus or minus one

getUTCFullYear()method 
public function getUTCFullYear():Number

Player version: Flash Player 5

Returns the four-digit year of the specified Date object, according to universal time.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and uses Date.getUTCFullYear() and Date.getFullYear(). The value returned by Date.getUTCFullYear() may differ from the value returned by Date.getFullYear() if today's date is December 31 or January 1, depending on the relationship between your local time zone and universal time.
var today_date:Date = new Date();
trace(today_date.getFullYear()); // display based on local timezone
trace(today_date.getUTCFullYear()); // displays getYear() plus or minus 1

getUTCHours()method 
public function getUTCHours():Number

Player version: Flash Player 5

Returns the hour (an integer from 0 to 23) of the specified Date object, according to universal time.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and uses Date.getUTCHours() and Date.getHours(). The value returned by Date.getUTCHours() may differ from the value returned by Date.getHours(), depending on the relationship between your local time zone and universal time.
var today_date:Date = new Date();
trace(today_date.getHours()); // display based on local timezone
trace(today_date.getUTCHours()); // display equals getHours() plus or minus 12

getUTCMilliseconds()method 
public function getUTCMilliseconds():Number

Player version: Flash Player 5

Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to universal time.

Returns
Number — An integer.

Example
The following example creates a new Date object and uses getUTCMilliseconds() to return the milliseconds value from the Date object.
var today_date:Date = new Date();
trace(today_date.getUTCMilliseconds());

getUTCMinutes()method 
public function getUTCMinutes():Number

Player version: Flash Player 5

Returns the minutes (an integer from 0 to 59) of the specified Date object, according to universal time.

Returns
Number — An integer.

Example
The following example creates a new Date object and uses getUTCMinutes() to return the minutes value from the Date object:
var today_date:Date = new Date();
trace(today_date.getUTCMinutes()); 

getUTCMonth()method 
public function getUTCMonth():Number

Player version: Flash Player 5

Returns the month (0 [January] to 11 [December]) of the specified Date object, according to universal time.

Returns
Number — An integer.

See also


Example
The following example creates a new Date object and uses Date.getUTCMonth() and Date.getMonth(). The value returned by Date.getUTCMonth() can differ from the value returned by Date.getMonth() if today's date is the first or last day of a month, depending on the relationship between your local time zone and universal time.
var today_date:Date = new Date();
trace(today_date.getMonth()); // output based on local timezone
trace(today_date.getUTCMonth()); // output equals getMonth() plus or minus 1

getUTCSeconds()method 
public function getUTCSeconds():Number

Player version: Flash Player 5

Returns the seconds (an integer from 0 to 59) of the specified Date object, according to universal time.

Returns
Number — An integer.

Example
The following example creates a new Date object and uses getUTCSeconds() to return the seconds value from the Date object:
var today_date:Date = new Date();
trace(today_date.getUTCSeconds()); 

getUTCYear()method 
public function getUTCYear():Number

Player version: Flash Player 8

Returns the year of this Date according to universal time (UTC). The year is the full year minus 1900. For example, the year 2000 is represented as 100.

Returns
Number — An integer.

Example
The following example creates a new Date object and uses Date.getUTCFullYear() and Date.getFullYear(). The value returned by Date.getUTCFullYear() may differ from the value returned by Date.getFullYear() if today's date is December 31 or January 1, depending on the relationship between your local time zone and universal time.
var today_date:Date = new Date();
trace(today_date.getFullYear()); // display based on local timezone
trace(today_date.getUTCFullYear()); // displays getYear() plus or minus 1

getYear()method 
public function getYear():Number

Player version: Flash Player 5

Returns the year of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running. The year is the full year minus 1900. For example, the year 2000 is represented as 100.

Returns
Number — An integer.

See also


Example
The following example creates a Date object with the month and year set to May 2004. The Date.getYear() method returns 104, and Date.getFullYear() returns 2004:
var today_date:Date = new Date(2004,4);
trace(today_date.getYear()); // output: 104
trace(today_date.getFullYear()); // output: 2004

setDate()method 
public function setDate(date:Number):Number

Player version: Flash Player 5

Sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running.

Parameters
date:Number — An integer from 1 to 31.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setDate() to change the date to May 25, 2004:
var today_date:Date = new Date(2004,4,15);
trace(today_date.getDate()); //displays 15
today_date.setDate(25);
trace(today_date.getDate()); //displays 25

setFullYear()method 
public function setFullYear(year:Number, [month:Number], [date:Number]):Number

Player version: Flash Player 5

Sets the year of the specified Date object, according to local time and returns the new time in milliseconds. If the month and date parameters are specified, they are set to local time. Local time is determined by the operating system on which Flash Player is running.

Calling this method does not modify the other fields of the specified Date object but Date.getUTCDay() and Date.getDay() can report a new value if the day of the week changes as a result of calling this method.

Parameters
year:Number — A four-digit number specifying a year. Two-digit numbers do not represent four-digit years; for example, 99 is not the year 1999, but the year 99.
 
month:Number [optional] — An integer from 0 (January) to 11 (December). If you omit this parameter, the month field of the specified Date object will not be modified.
 
date:Number [optional] — A number from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified.

Returns
Number — An integer.

See also


Example
The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setFullYear() to change the date to May 15, 2002:
var my_date:Date = new Date(2004,4,15);
trace(my_date.getFullYear()); //output: 2004
my_date.setFullYear(2002);
trace(my_date.getFullYear()); //output: 2002

setHours()method 
public function setHours(hour:Number):Number

Player version: Flash Player 5

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

Parameters
hour:Number — An integer from 0 (midnight) to 23 (11 p.m.).

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and uses Date.setHours() to change the time to 4:00 p.m.:
var my_date:Date = new Date(2004,4,15,8);
trace(my_date.getHours()); // output: 8
my_date.setHours(16);
trace(my_date.getHours()); // output: 16

setMilliseconds()method 
public function setMilliseconds(millisecond:Number):Number

Player version: Flash Player 5

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

Parameters
millisecond:Number — An integer from 0 to 999.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the date to 8:30 a.m. on May 15, 2004 with the milliseconds value set to 250, and then uses Date.setMilliseconds() to change the milliseconds value to 575:
var my_date:Date = new Date(2004,4,15,8,30,0,250);
trace(my_date.getMilliseconds()); // output: 250
my_date.setMilliseconds(575);
trace(my_date.getMilliseconds()); // output: 575

setMinutes()method 
public function setMinutes(minute:Number):Number

Player version: Flash Player 5

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

Parameters
minute:Number — An integer from 0 to 59.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and then uses Date.setMinutes() to change the time to 8:30 a.m.:
var my_date:Date = new Date(2004,4,15,8,0);
trace(my_date.getMinutes()); // output: 0
my_date.setMinutes(30);
trace(my_date.getMinutes()); // output: 30

setMonth()method 
public function setMonth(month:Number, [date:Number]):Number

Player version: Flash Player 5

Sets the month 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
month:Number — An integer from 0 (January) to 11 (December).
 
date:Number [optional] — An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setMonth() to change the date to June 15, 2004:
var my_date:Date = new Date(2004,4,15);
trace(my_date.getMonth()); //output: 4
my_date.setMonth(5);
trace(my_date.getMonth()); //output: 5

setSeconds()method 
public function setSeconds(second:Number):Number

Player version: Flash Player 5

Sets the seconds 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
second:Number — An integer from 0 to 59.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses Date.setSeconds() to change the time to 8:00:45 a.m.:
var my_date:Date = new Date(2004,4,15,8,0,0);
trace(my_date.getSeconds()); // output: 0
my_date.setSeconds(45);
trace(my_date.getSeconds()); // output: 45

setTime()method 
public function setTime(millisecond:Number):Number

Player version: Flash Player 5

Sets the date for the specified Date object in milliseconds since midnight on January 1, 1970, and returns the new time in milliseconds.

Parameters
millisecond:Number — A number; an integer value where 0 is midnight on January 1, universal time.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and uses Date.setTime() to change the time to 8:30 a.m.:
var my_date:Date = new Date(2004,4,15,8,0,0);
var myDate_num:Number = my_date.getTime(); // convert my_date to milliseconds
myDate_num += 30 * 60 * 1000; // add 30 minutes in milliseconds
my_date.setTime(myDate_num); // set my_date Date object 30 minutes forward
trace(my_date.getFullYear()); // output: 2004
trace(my_date.getMonth()); // output: 4
trace(my_date.getDate()); // output: 15
trace(my_date.getHours()); // output: 8
trace(my_date.getMinutes()); // output: 30

setUTCDate()method 
public function setUTCDate(date:Number):Number

Player version: Flash Player 5

Sets the date for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but Date.getUTCDay() and Date.getDay() can report a new value if the day of the week changes as a result of calling this method.

Parameters
date:Number — A number; an integer from 1 to 31.

Returns
Number — An integer.

See also


Example
The following example initially creates a new Date object with today's date, uses Date.setUTCDate() to change the date value to 10, and changes it again to 25:
var my_date:Date = new Date();
my_date.setUTCDate(10);
trace(my_date.getUTCDate()); // output: 10
my_date.setUTCDate(25);
trace(my_date.getUTCDate()); // output: 25

setUTCFullYear()method 
public function setUTCFullYear(year:Number, [month:Number], [date:Number]):Number

Player version: Flash Player 5

Sets the year for the specified Date object (my_date) in universal time and returns the new time in milliseconds.

Optionally, this method can also set the month and date represented by the specified Date object. Calling this method does not modify the other fields of the specified Date object, but Date.getUTCDay() and Date.getDay() can report a new value if the day of the week changes as a result of calling this method.

Parameters
year:Number — An integer that represents the year specified as a full four-digit year, such as 2000.
 
month:Number [optional] — An integer from 0 (January) to 11 (December). If you omit this parameter, the month field of the specified Date object will not be modified.
 
date:Number [optional] — An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified.

Returns
Number — An integer.

See also


Example
The following example initially creates a new Date object with today's date, uses Date.setUTCFullYear() to change the year value to 2001, and changes the date to May 25, 1995:
var my_date:Date = new Date();
my_date.setUTCFullYear(2001);
trace(my_date.getUTCFullYear()); // output: 2001
my_date.setUTCFullYear(1995, 4, 25);
trace(my_date.getUTCFullYear()); // output: 1995
trace(my_date.getUTCMonth()); // output: 4
trace(my_date.getUTCDate()); // output: 25

setUTCHours()method 
public function setUTCHours(hour:Number, [minute:Number], [second:Number], [millisecond:Number]):Number

Player version: Flash Player 5

Sets the hour for the specified Date object in universal time and returns the new time in milliseconds.

Parameters
hour:Number — A number; an integer from 0 (midnight) to 23 (11 p.m.).
 
minute:Number [optional] — A number; an integer from 0 to 59. If you omit this parameter, the minutes field of the specified Date object will not be modified.
 
second:Number [optional] — A number; an integer from 0 to 59. If you omit this parameter, the seconds field of the specified Date object will not be modified.
 
millisecond:Number [optional] — A number; an integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified Date object will not be modified.

Returns
Number — An integer.

Example
The following example initially creates a new Date object with today's date, uses Date.setUTCHours() to change the time to 8:30 a.m., and changes the time again to 5:30:47 p.m.:
var my_date:Date = new Date();
my_date.setUTCHours(8,30);
trace(my_date.getUTCHours()); // output: 8
trace(my_date.getUTCMinutes()); // output: 30
my_date.setUTCHours(17,30,47);
trace(my_date.getUTCHours()); // output: 17
trace(my_date.getUTCMinutes()); // output: 30
trace(my_date.getUTCSeconds()); // output: 47

setUTCMilliseconds()method 
public function setUTCMilliseconds(millisecond:Number):Number

Player version: Flash Player 5

Sets the milliseconds for the specified Date object in universal time and returns the new time in milliseconds.

Parameters
millisecond:Number — An integer from 0 to 999.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the date to 8:30 a.m. on May 15, 2004 with the milliseconds value set to 250, and uses Date.setUTCMilliseconds() to change the milliseconds value to 575:
var my_date:Date = new Date(2004,4,15,8,30,0,250);
trace(my_date.getUTCMilliseconds()); // output: 250
my_date.setUTCMilliseconds(575);
trace(my_date.getUTCMilliseconds()); // output: 575

setUTCMinutes()method 
public function setUTCMinutes(minute:Number, [second:Number], [millisecond:Number]):Number

Player version: Flash Player 5

Sets the minute for the specified Date object in universal time and returns the new time in milliseconds.

Parameters
minute:Number — An integer from 0 to 59.
 
second:Number [optional] — An integer from 0 to 59. If you omit this parameter, the seconds field of the specified Date object will not be modified.
 
millisecond:Number [optional] — An integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified Date object will not be modified.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and uses Date.setUTCMinutes() to change the time to 8:30 a.m.:
var my_date:Date = new Date(2004,4,15,8,0);
trace(my_date.getUTCMinutes()); // output: 0
my_date.setUTCMinutes(30);
trace(my_date.getUTCMinutes()); // output: 30

setUTCMonth()method 
public function setUTCMonth(month:Number, [date:Number]):Number

Player version: Flash Player 5

Sets the month, and optionally the day, for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but Date.getUTCDay() and Date.getDay() might report a new value if the day of the week changes as a result of specifying a value for the date parameter.

Parameters
month:Number — An integer from 0 (January) to 11 (December).
 
date:Number [optional] — An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified.

Returns
Number — An integer.

See also


Example
The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setMonth() to change the date to June 15, 2004:
var today_date:Date = new Date(2004,4,15);
trace(today_date.getUTCMonth()); // output: 4
today_date.setUTCMonth(5);
trace(today_date.getUTCMonth()); // output: 5

setUTCSeconds()method 
public function setUTCSeconds(second:Number, [millisecond:Number]):Number

Player version: Flash Player 5

Sets the seconds for the specified Date object in universal time and returns the new time in milliseconds.

Parameters
second:Number — An integer from 0 to 59.
 
millisecond:Number [optional] — An integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified Date object will not be modified.

Returns
Number — An integer.

Example
The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses Date.setSeconds() to change the time to 8:30:45 a.m.:
var my_date:Date = new Date(2004,4,15,8,0,0);
trace(my_date.getUTCSeconds()); // output: 0
my_date.setUTCSeconds(45);
trace(my_date.getUTCSeconds()); // output: 45

setYear()method 
public function setYear(year:Number):Number

Player version: Flash Player 5

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

toString()method 
public function toString():String

Player version: Flash Player 5

Returns a string value for the specified date object in a readable format.

Returns
String — A string.

Example
The following example returns the information in the dateOfBirth_date Date object as a string. The output from the trace statements are in local time and vary accordingly. For Pacific Daylight Time the output is seven hours earlier than universal time: Mon Aug 12 18:15:00 GMT-0700 1974.
var dateOfBirth_date:Date = new Date(74, 7, 12, 18, 15);
trace (dateOfBirth_date);
trace (dateOfBirth_date.toString());

UTC()method 
public static function UTC(year:Number, month:Number, [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]):Number

Player version: Flash Player 5

Returns the number of milliseconds between midnight on January 1, 1970, universal time, and the time specified in the parameters. This is a static method that is invoked through the Date object constructor, not through a specific Date object. This method lets you create a Date object that assumes universal time, whereas the Date constructor assumes local time.

Parameters
year:Number — A four-digit integer that represents the year (for example, 2000).
 
month:Number — An integer from 0 (January) to 11 (December).
 
date:Number [optional] — An integer from 1 to 31.
 
hour:Number [optional] — An integer from 0 (midnight) to 23 (11 p.m.).
 
minute:Number [optional] — An integer from 0 to 59.
 
second:Number [optional] — An integer from 0 to 59.
 
millisecond:Number [optional] — An integer from 0 to 999.

Returns
Number — An integer.

Example
The following example creates a new maryBirthday_date Date object defined in universal time. This is the universal time variation of the example used for the new Date constructor method. The output is in local time and varies accordingly. For Pacific Daylight Time the output is seven hours earlier than UTC: Sun Aug 11 17:00:00 GMT-0700 1974.
var maryBirthday_date:Date = new Date(Date.UTC(1974, 7, 12));
trace(maryBirthday_date); 

valueOf()method 
public function valueOf():Number

Player version: Flash Player 5

Returns the number of milliseconds since midnight January 1, 1970, universal time, for this Date.

Returns
Number — The number of milliseconds.