Siebel eScript Language Reference > Methods Reference > Date and Time Methods >

About the Date Constructor


The Date constructor instantiates a new date object. If you include an argument, then it returns a date object that includes the date according to the argument. To create a date object that Siebel CRM sets to the current date and time, you can use the new operator as you would with any object.

Format A

var dateVar = new Date;

Format B

var dateVar = new Date(milliseconds);

Format C

var dateVar = new Date(dateString);

Format D

var dateVar = new Date(year, month, day);

Format E

var dateVar = new Date(year, month, day, hours, minutes, seconds);

Arguments

Table 62 describes arguments for the date constructor.

Table 62. Arguments for the Date Constructor
Argument
Description

dateString

A string that includes a date and optional time.

year

A year. If the year is between 1950 and 2050, then you can include only the final two digits. Otherwise, you must include four digits. For more information, see Caution About Using Two Digit Dates.

month

For more information, see Values for Dates and Times.

day

hours

minutes

seconds

milliseconds

The number of milliseconds since January 1, 1970.

Usage for Format B

Format B returns a date and time that includes the number of milliseconds since midnight, January 1, 1970. Using milliseconds is a standard way of including dates and times. It simplifies calculating the amount of time between one date and another. It is recommended that you configure Siebel CRM to convert a date to milliseconds before it performs a calculation on the date.

Usage for Format C

Format C accepts a string that includes a date and an optional time. The format for this string includes one or more of the following fields, in any order:

month day, year hours:minutes:seconds

For example:

"October 13, 1995 13:13:15"

This string specifies a date of October 13, 1995 and a time of one thirteen and 15 seconds PM. In a 24 hour format, this value is 13:13 hours and 15 seconds. The time specification is optional. If you include it, then the seconds specification is optional.

Siebel CRM can pass the result of the BusComp.GetFieldValue(datetime field) method to the date constructor. The GetFieldValue method always returns date fields using the following format:

MM/DD/YYYY hh:mm:ss

Siebel CRM interprets the time in a date string as local time, according to the time zone setting of the operating system. If you require Siebel CRM to interpret the time as UTC time, then you can append GMT to the date string. For example:

"07/09/2004 14:22:00 GMT"

If a business component field includes a UTC time rather than a local time, then you can append GMT to the code to configure Siebel CRM to pass is to the date constructor. For example:

var utctime = new Date(GetFieldValue("UTC Time") + " GMT");

Usage for Format D and E

Format for formats D and E are self-explanatory. You configure Siebel CRM to pass arguments to them as integers.

Example

The following example includes a date constructor:

var aDate = new Date(1802, 6, 23)

This example creates a date object that contains a date of July 23, 1802.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.