Date
A date/time object.
Go to Method Listing
Methods:
Date, UTC, getDate, getDay, getFullYear, getHours, getMilliseconds, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getUTCDate, getUTCDay, getUTCFullYear, getUTCHours, getUTCMilliseconds, getUTCMinutes, getUTCMonth, getUTCSeconds, getYear, parse, setDate, setFullYear, setHours, setMilliseconds, setMinutes, setMonth, setSeconds, setTime, setUTCDate, setUTCFullYear, setUTCHours, setUTCMilliseconds, setUTCMinutes, setUTCMonth, setUTCSeconds, setYear, toDateString, toGMTString, toLocaleDateString, toLocaleString, toLocaleTimeString, toSource, toString, toTimeString, toUTCString, valueOf
Method Listing
Constructor
Date Date (year:Number, [month:Number=Number], [day:Number=Number], [hours:Number=Number], [min:Number=Number], [sec:Number=Number], [ms:Number=Number])
Returns a new Date object holding the current date and time.
If parameters are supplied, returns a new Date object holding the supplied date and time.
Parameter |
Type |
Description |
---|---|---|
year |
The year expressed in four digits. |
|
month |
Number (range 0 - 11) |
An integer value from 0 (Jan) to 11 (Dec). (default: 0) |
day |
Number (range 1 - 31) |
An integer value from 1 to 31, If this argument is not supplied, its value is set to 0. (default: 0) |
hours |
Number (range 0 - 23) |
An integer value from 0 (midnight) to 23 (11 PM). If this argument is not supplied, its value is set to 0. (default: 0) |
min |
Number (range 0 - 59) |
An integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) |
sec |
Number (range 0 - 59) |
An Integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) |
ms |
Number (range 0 - 999) |
An integer value from 0 to 999. If this argument is not supplied, its value is set to 0. (default: 0) |
Date UTC (year:Number, [month:Number=Number], [day:Number=Number], [hours:Number=Number], [min:Number=Number], [sec:Number=Number], [ms:Number=Number])
Returns the number of milliseconds between midnight January 1, 1970, UTC, and the specified time.
Parameter |
Type |
Description |
---|---|---|
year |
The year expressed in four digits, for example, 2001. To indicate for a year from 1900 to 1999, you can specify a value from 0 to 99. |
|
month |
Number (range 0 - 11) |
An integer value from 0 (Jan) to 11 (Dec). (default: 0) |
day |
Number (range 1 - 31) |
An integer value from 1 to 31, If this argument is not supplied, its value is set to 0. (default: 0) |
hours |
Number (range 0 - 23) |
An integer value from 0 (midnight) to 23 (11 PM). If this argument is not supplied, its value is set to 0. (default: 0) |
min |
Number (range 0 - 59) |
An integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) |
sec |
Number (range 0 - 59) |
An Integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) |
ms |
Number (range 0 - 999) |
An integer value from 0 to 999. If this argument is not supplied, its value is set to 0. (default: 0) |
Number getDate ()
Returns the day of the month of the specified Date object in local time.
Number getDay ()
Returns the day of the week for the specified Date object in local time.
This is an integer from 0 (Sunday) to 6 (Saturday). Returns the day of the week for date.
Number getFullYear ()
Returns the four digit year of the specified Date object in local time.
Number getHours ()
Returns the hour of the specified Date object in local time.
Number getMilliseconds ()
Returns the milliseconds of the specified Date object in local time.
Number getMinutes ()
Returns the minutes of the specified Date object in local time.
Number getMonth ()
Returns the month of the specified Date object in local time.
Number getSeconds ()
Returns the seconds of the specified Date object in local time.
Number getTime ()
Returns the number of milliseconds since midnight January 1,1970 UTC for the specified Date object.
Number getTimezoneOffset ()
Returns the difference in minutes between the computer's local time and UTC.
Number getUTCDate ()
Returns the day of the month of the specified Date object according to UTC.
Number getUTCDay ()
Returns the day of the week for the specified Date object according to UTC.
Number getUTCFullYear ()
Returns the four digit year of the specified Date object according to UTC.
Number getUTCHours ()
Returns the hour of the specified Date object according to UTC.
Number getUTCMilliseconds ()
Returns the milliseconds of the specified Date object according to UTC.
Number getUTCMinutes ()
Returns the minutes of the specified Date object according to UTC.
Number getUTCMonth ()
Returns the month of the specified Date object according to UTC.
Number getUTCSeconds ()
Returns the seconds of the specified Date object according to UTC.
Number getYear ()
Returns the year of the specified Date object, as a difference from 1900, in local time.
Date parse (text:String)
Parses a string, returning a new Date object. The string should be similar to the string returned bt toString().
Parameter |
Type |
Description |
---|---|---|
text |
The string to parse. |
Number setDate (date:Number)
Sets the day of the month of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
date |
Number (range 1 - 31) |
An integer from 1 to 31 indicating the day of the month. |
Number setFullYear (year:Number)
Sets the year of a specified Date object according to local time.
This method can also set month and date if those arguments are specified. Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
year |
A four-digit integer value indicating the year to set. |
Number setHours (hour:Number)
Sets the hours of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
hour |
Number (range 0 - 23) |
An integer value from 0 (midnight) to 23 (11 PM). |
Number setMilliseconds (ms:Number)
Sets the milliseconds of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
ms |
Number (range 0 - 999) |
An integer value from 0 to 999. |
Number setMinutes (minutes:Number)
Sets the minutes of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
minutes |
Number (range 0 - 59) |
An integer value from 0 to 59. |
Number setMonth (month:Number)
Sets the month of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
month |
Number (range 0 - 11) |
An integer value from 0 (Jan) to 11 (Dec). |
Number setSeconds (seconds:Number)
Sets the seconds of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
seconds |
Number (range 0 - 59) |
An integer value from 0 to 59. |
Number setTime (ms:Number)
Sets the date of a specified Date object in milliseconds since midnight, January 1, 1970.
Returns the value of ms.
Parameter |
Type |
Description |
---|---|---|
ms |
An integer indicating the number of milliseconds between the date set and midnight, January 1, 1970. |
Number setUTCDate (date:Number)
Sets the date of a specified Date object according to universal time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970 in UTC time.
Parameter |
Type |
Description |
---|---|---|
date |
Number (range 1 - 31) |
An integer from 1 to 31 indicating the day of the month. |
Number setUTCFullYear (year:Number)
Sets the year of a specified Date object according to UTC, can also set the month and date.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
year |
The year expressed in four digits. |
Number setUTCHours (hours:Number)
Sets the hours of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
hours |
Number (range 0 - 23) |
An integer value from 0 (midnight) to 23 (11 PM) indicating the hour to be set. |
Number setUTCMilliseconds (ms:Number)
Sets the milliseconds of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
ms |
Number (range 0 - 999) |
An integer value in the range of 0 to 999 indicating the number of milliseconds to set. |
Number setUTCMinutes (min:Number)
Sets the minutes of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
min |
Number (range 0 - 59) |
An integer value in the range 0 to 59 indicating the number of minutes to be set. |
Number setUTCMonth (month:Number)
Sets the month of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
month |
Number (range 0 - 11) |
An integer value in the range 0 (Jan.) to 11 (Dec.) indicating the month to set. |
Number setUTCSeconds (sec:Number)
Sets the seconds of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.
Parameter |
Type |
Description |
---|---|---|
sec |
Number (range 0 - 59) |
An integer value in the range 0 to 59 indicating the number of seconds to set. |
Number setYear (year:Number)
Sets the year of a specified Date object according to local time, as a difference between the current year and 1900.
Returns the number of milliseconds between the date set and midnight, January 1, 1970.
Parameter |
Type |
Description |
---|---|---|
year |
An integer value indicating the year to set. The method interprets a 1- or 2- digit value to mean the 1900s; for example, 13 is interpreted to mean 1913. |
String toDateString ()
Returns the date as a string.
String toGMTString ()
Returns the date and time adjusted to GMT (UTC) as a string.
String toLocaleDateString ()
Returns the date as a localized string.
String toLocaleString ()
Returns a string value representing the date and time stored in the Date object in human readable format (localized).
String toLocaleTimeString ()
Returns the time as a localized string.
String toSource ()
Creates a string representation of this object that can be fed back to eval() to re-create an object. Works only with built-in classes.
String toString ()
Returns a string value representing the date and time stored in the Date object in human readable format.
Returns the following string is an example of the format returned by this method: Mon Aug 13, 10:54:21 GMT-0700 2001.
String toTimeString ()
Returns the time as a string.
String toUTCString ()
Returns the date and time adjusted to UTC as a string.
Number valueOf ()
The valueOf() method returns the number of milliseconds that have passed since midnight, Returns an integer.