View comments | RSS feed

Date


Object
    |
    +-Date

public class Date
extends Object

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.

Availability: ActionScript 1.0; Flash Player 5

Property summary

Properties inherited from class Object

constructor, __proto__, prototype, __resolve


Constructor summary

Signature

Description

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.

Method summary

Modifiers

Signature

Description

 

getDate() : Number

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

 

getDay() : Number

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

 

getFullYear() : Number

Returns the full year (a four-digit number, such as 2000) of the specified Date object, according to local time.

 

getHours() : Number

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

 

getMilliseconds() : Number

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

 

getMinutes() : Number

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

 

getMonth() : Number

Returns the month (0 for January, 1 for February, and so on) of the specified Date object, according to local time.

 

getSeconds() : Number

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

 

getTime() : Number

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

 

getTimezoneOffset() : Number

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

 

getUTCDate() : Number

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

 

getUTCDay() : Number

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

 

getUTCFullYear() : Number

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

 

getUTCHours() : Number

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

 

getUTCMilliseconds() : Number

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

 

getUTCMinutes() : Number

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

 

getUTCMonth() : Number

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

 

getUTCSeconds() : Number

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

 

getUTCYear() : Number

Returns the year of this Date according to universal time (UTC).

 

getYear() : Number

Returns the year of the specified Date object, according to local time.

 

setDate(date:Number) : Number

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.

 

setHours(hour:Number) : Number

Sets the hours for the specified Date object according to local time and returns the new time in milliseconds.

 

setMilliseconds(millisecond:Number) : Number

Sets the milliseconds for the specified Date object according to local time and returns the new time in milliseconds.

 

setMinutes(minute:Number) : Number

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.

 

setSeconds(second:Number) : Number

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.

 

setUTCDate(date:Number) : Number

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.

 

setUTCMilliseconds(millisecond:Number) : Number

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.

 

setYear(year:Number) : Number

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

 

toString() : String

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

static

UTC(year:Number, month:Number, [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]) : Number

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

 

valueOf() : Number

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



Version 8

Comments


orangechicken said on Mar 23, 2006 at 4:47 PM :
Could you add the proper way to compare dates? Look at the following code to see the confusion.

var d1:Date = new Date( 1970, 0 );
var d2:Date = new Date( 1970, 0 );
trace( d1 == d2 ); // false
trace( d1 <= d2 ); // true
trace( d1 >= d2 ); // TRUE?!

If something is *both* greater than or equal to *and* less than or equal to another thing, the only possibility is that the something *is equal to* the other thing. Yet that exact comparison above fails.

Huh?
graphXdziner said on Jun 14, 2006 at 9:32 AM :
var d1:Date = new Date( 1970, 0 );
var d2:Date = new Date( 1970, 0 );

var dT1:Number = d1.getTime();
var dT2:Number = d2.getTime();

trace( dT1 == dT2 ); // true
trace( dT1 <= dT2 ); // true
trace( dT1 >= dT2 ); // true
No screen name said on Apr 20, 2007 at 11:55 AM :
How can we determine if DST is in effect or not for the current locale?

 

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

Current page: http://livedocs.adobe.com/flash/8/main/00002128.html