D-E > Date (object)

 

Date (object)

The Date object 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 the Flash Player is running. The methods of the Date object are not static, but apply only to the individual instance of the Date object specified when the method is called. The Date.UTC method is an exception; it is a static method.

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

Windows—the Date object automatically adjusts its output for daylight saving time. The Date object detects whether daylight saving time is employed in the current locale, and if so, it detects what the standard-to-daylight-saving-time transition date and times are. However, the transition dates currently in effect are applied to dates in the past and the future, so the daylight saving time bias may be calculated incorrectly for dates in the past when the locale had different transition dates.

Mac OS 8 and 9—the Date object uses the current daylight-saving-time bias, regardless of the date or time being calculated. For example, in the U.S. Pacific time zone during August, when daylight saving time (DST) is in effect, a Date object containing the date Jan 1 2001 still reports DST time even though DST isn't in effect during January. This problem cannot be remedied on Mac OS 8 or 9 because a time zone information database is not available.

Mac OS X—the Date object automatically adjusts its output for daylight saving time. The timezone information database in Mac OS X is used to determine whether any date or time in the present or past should have a daylight-saving-time bias applied.

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

Mac OS 8 and 9—the behavior is the same as described for Flash Player 6.

Windows—the U.S. rules for daylight saving time are always applied, which leads to incorrect transitions in Europe and other areas that employ daylight saving time but have different transition times than the U.S. Flash correctly detects whether DST is employed in the current locale.

To call the methods of the Date object, you must first create an instance of the Date object using the constructor for the Date object.

The Date object requires Flash Player 5.

 
Method summary for Date object

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 object

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

An integer.

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 = new Date();

The following example creates a new Date object for Gary's birthday, August 7, 1974.

gary_birthday = new Date (74, 7, 7); 

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

myDate = new Date();
dateTextField = ((myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myDate.getFullYear());