Date (Date - JavaScript)
Creates a Date object representing the current date and time, or a specified date and time.
Defined in
Date (Standard - JavaScript)Syntax
Date()
Date(value:long)
Date(value:string)
Date(year:int,
month:int,
day:int)
Date(year:int,
month:int,
day:int,
hour:int)
Date(year:int,
month:int,
day:int,
hours:int,
minutes:int)
Date(year:int,
month:int,
day:int,
hours:int,
minutes:int,
seconds:int)
Date(year:int,
month:int,
day:int,
hours:int,
minutes:int,
seconds:int,
ms:int)
Parameters | Description |
---|---|
value - long |
Numeric value of a date, that is, the number of milliseconds from 0 hours on January 1, 1970. |
value - string |
String representing the date in the format generated by toString (Date - JavaScript). |
year |
The year. Specify the entire year, for example, 2006 not 06 . |
month |
The month where 0 is January and 11 is December. |
day |
The day of the month where 1 is the first day. Defaults to 1. |
hours |
The hour where 1 is 1:00 AM and 13 is 1:00 PM. Defaults to 0 (12:00 AM). |
min |
The minute where 1 is the first minute. Defaults to 0. |
sec |
The second where 1 is the first second. Defaults to 0. |
ms |
The millisecond where 1 is the first millisecond. Defaults to 0. |
Usage
ForDate()
, all elements
are set to the current date and time. For a signature with integer
parameters, unspecified elements are set to the default.Examples
(1) This computed label displays a date representing the current time:try {
var date = new Date();
return date.toString() + " " +
date.getSeconds() + " " +
date.getMilliseconds(); // 11/22/06 1:38 PM 47 906
} catch(e) {
return e
}
(2) This computed label displays a date representing
November of 2006:
try {
var date = new Date(2006, 10);
return date.toString() + " " +
date.getSeconds() + " " +
date.getMilliseconds(); // 11/1/06 12:00 AM 0 0
} catch(e) {
return e
}
(3) This computed label changes the year of the
current date and displays it as a new Date object.
var date = new Date();
new Date(date.setFullYear(2001)).toString()