Date class

Availability

Flash Player 5.

Description

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.

Method summary for the Date class

Method

Description

Date.getDate()

Returns the day of the month according to local time.

Date.getDay()

Returns the day of the week according to local time.

Date.getFullYear()

Returns the four-digit year according to local time.

Date.getHours()

Returns the hour according to local time.

Date.getMilliseconds()

Returns the milliseconds according to local time.

Date.getMinutes()

Returns the minutes according to local time.

Date.getMonth()

Returns the month according to local time.

Date.getSeconds()

Returns the seconds according to local time.

Date.getTime()

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

Date.getTimezoneOffset()

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

Date.getUTCDate()

Returns the day (date) of the month according to universal time.

Date.getUTCDay()

Returns the day of the week according to universal time.

Date.getUTCFullYear()

Returns the four-digit year according to universal time.

Date.getUTCHours()

Returns the hour according to universal time.

Date.getUTCMilliseconds()

Returns the milliseconds according to universal time.

Date.getUTCMinutes()

Returns the minutes according to universal time.

Date.getUTCMonth()

Returns the month according to universal time.

Date.getUTCSeconds()

Returns the seconds according to universal time.

Date.getYear()

Returns the year according to local time.

Date.setDate()

Sets the day of the month according to local time. Returns the new time in milliseconds.

Date.setFullYear()

Sets the full year according to local time. Returns the new time in milliseconds.

Date.setHours()

Sets the hour according to local time. Returns the new time in milliseconds.

Date.setMilliseconds()

Sets the milliseconds according to local time. Returns the new time in milliseconds.

Date.setMinutes()

Sets the minutes according to local time. Returns the new time in milliseconds.

Date.setMonth()

Sets the month according to local time. Returns the new time in milliseconds.

Date.setSeconds()

Sets the seconds according to local time. Returns the new time in milliseconds.

Date.setTime()

Sets the date in milliseconds. Returns the new time in milliseconds.

Date.setUTCDate()

Sets the date according to universal time. Returns the new time in milliseconds.

Date.setUTCFullYear()

Sets the year according to universal time. Returns the new time in milliseconds.

Date.setUTCHours()

Sets the hour according to universal time. Returns the new time in milliseconds.

Date.setUTCMilliseconds()

Sets the milliseconds according to universal time. Returns the new time in milliseconds.

Date.setUTCMinutes()

Sets the minutes according to universal time. Returns the new time in milliseconds.

Date.setUTCMonth()

Sets the month according to universal time. Returns the new time in milliseconds.

Date.setUTCSeconds()

Sets the seconds according to universal time. Returns the new time in milliseconds.

Date.setYear()

Sets the year according to local time.

Date.toString()

Returns a string value representing the date and time stored in the specified Date object.

Date.UTC()

Returns the number of milliseconds between midnight on January 1, 1970, universal time, and the specified time.

Constructor for the Date class

Availability

Flash Player 5.

Usage

new Date()
new Date(year, month [, date [, hour [, minute [, second [, millisecond ]]]]])

Parameters

year A value of 0 to 99 indicates 1900 though 1999; otherwise all four digits of the year must be specified.

month An integer from 0 (January) to 11 (December).

date An integer from 1 to 31. This parameter is optional.

hour An integer from 0 (midnight) to 23 (11 p.m.).

minute An integer from 0 to 59. This parameter is optional.

second An integer from 0 to 59. This parameter is optional.

millisecond An integer from 0 to 999. This parameter is optional.

Returns

Nothing.

Description

Object; constructs a new Date object that holds the current date and time, or the date specified.

Example

The following example retrieves the current date and time.

now_date = new Date();

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

garyBirthday_date = new Date (74, 7, 12); 

The following example creates a new Date object, concatenates the returned values of Date.getMonth(), Date.getDate(), and Date.getFullYear(), and displays them in the text field specified by the variable date_str.

today_date = new Date();
date_str = ((today_date.getMonth() + 1) + "/" + today_date.getDate() + "/" + today_date.getFullYear());