Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference > Siebel eScript Commands > The Date Object >
The Date Constructor
The Date constructor instantiates a new Date object.
To create a Date object that is set to the current date and time, use the new operator, as you would with any object.
Syntax A
var dateVar = new Date;
There are several ways to create a Date object that is set to a date and time. The following lines each demonstrate ways to get and set dates and times.
Syntax B
var dateVar = new Date(milliseconds);
Syntax C
var dateVar = new Date(dateString);
Syntax D
var dateVar = new Date(year, month, day);
Syntax E
var dateVar = new Date(year, month, day, hours, minutes, seconds);
Returns
If a parameter is specified, a Date object representing the date specified by the parameter.
Usage
Syntax B returns a date and time represented by the number of milliseconds since midnight, January 1, 1970. This representation by milliseconds is a standard way of representing dates and times that makes it easy to calculate the amount of time between one date and another. However, the recommended technique is to convert dates to milliseconds format before doing calculations.
Syntax C accepts a string representing a date and optional time. The format of such a string contains one or more of the following fields, in any order:
month day, year hours:minutes:seconds
For example, the following string:
"October 13, 1995 13:13:15"
specifies the date, October 13, 1995, and the time, one thirteen and 15 seconds PM, which, expressed in 24-hour time, is 13:13 hours and 15 seconds. The time specification is optional; if it is included, the seconds specification is optional.
Syntax forms D and E are self-explanatory. Parameters passed to them are integers.
Example
The following line of code:
var aDate = new Date(1776, 6, 4)
creates a Date object containing the date July 4, 1776.
Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference Published: 18 April 2003 |