This is the script counterpart to the QDateTime type used in the C++ SDK.
Date Time String Format
ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 Extended Format.
The format is as follows:
Where the fields are as follows:
This format includes the date-only forms:
It also includes date-time forms that consist of one of the above date-only forms immediately followed by one of the following time forms with an optional time zone offset appended:
Return Value:
Number : parse( String dateString )
Parses the given date string and returns the milliseconds since midnight on the 1st of January 1970.
Parameter(s):
Return Value:
Number : UTC( Number year, Number month, Number date=0, Number hour=0, Number minutes=0, Number seconds=0, Number milliseconds=0 )
Parameter(s):
Return Value:
Date()
Default constructor. Creates a date and initializes it with the current date and time.
Date( Number year, Number month, Number date, Number hour=0, Number minutes=0, Number seconds=0, Number milliseconds=0 )
Creates a date with the given year, month, day; and optionally, hour, minutes, seconds, and milliseconds.
Parameter(s):
Creates a date from a timestamp.
Parameter(s):
Creates a date from the formatted date string.
Parameter(s):
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getDate() ); //15
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getDay() ); //1
Number : getFullYear()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getFullYear() ); //2005
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getHours() ); //12
Return Value:
Number : getMinutes()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getMinutes() ); //30
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getMonth() ); //7
Number : getSeconds()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getSeconds() ); //30
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getTime() ); //1121452200000
See Also:
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getTimezoneOffset() );
Number : getUTCDate()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCDate() ); //15
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCDay() ); //1
Number : getUTCFullYear()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCFullYear() ); //2005
Number : getUTCHours()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCHours() ); //12
Return Value:
Number : getUTCMinutes()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCMinutes() ); //30
Number : getUTCMonth()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getMonth() ); //7
Number : getUTCSeconds()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getUTCSeconds() ); //30
See Also:
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.getYear() ); //105
void : setDate( Number dayOfTheMonth )
Sets the day of the month for the Date object.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setDate( 18 ); print( oDate.toString() ); //Thu Aug 18 2005 12:30:00 GMT-0600 (Mountain Daylight Time)
void : setFullYear( Number year, … )
Sets the year for the Date object, according to the Universal Coordinated Time (UTC). Optionally sets the month and date.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setFullYear( 2003 ); print( oDate.toString() ); //Fri Aug 15 2003 12:30:00 GMT-0600 (Mountain Daylight Time)
void : setHours( Number hours, … )
Sets the hours for the Date object. Optionally sets the minutes, seconds and milliseconds.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setHours( 10 ); print( oDate.toString() ); //Mon Aug 15 2005 10:30:00 GMT-0600 (Mountain Daylight Time)
void : setMilliseconds( Number milliseconds )
Sets the milliseconds for the Date object.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setMilliseconds( 10 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time)
void : setMinutes( Number minutes, … )
Sets the minutes for the Date object. Optionally sets the seconds and milliseconds.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setMinutes( 10 ); print( oDate.toString() ); //Mon Aug 15 2005 12:10:00 GMT-0600 (Mountain Daylight Time)
void : setMonth( Number month, … )
Sets the month of the year for the Date object. Optionally sets the date.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setMonth( 9 ); print( oDate.toString() ); //Sat Oct 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time)
void : setSeconds( Number seconds, … )
Sets the seconds for the Date object. Optionally sets the milliseconds.
Parameter(s):
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setSeconds( 20 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:20 GMT-0600 (Mountain Daylight Time)
void : setTime( Number milliseconds )
Sets the date and time, according to the local date and time.
Parameter(s):
Example:
var oDate = new Date(); oDate.setTime( 1124134200000 ); print( oDate.toString() ); //Mon Aug 15 2005 13:30:00 GMT-0600 (Mountain Daylight Time)
void : setUTCDate( Number dayOfTheMonth )
Sets the day of the month for the Date object, according to the Universal Coordinated Time (UTC).
Parameter(s):
void : setUTCFullYear( Number year, … )
Sets the year for the Date object. Optionally sets the month and date.
Parameter(s):
void : setUTCHours( Number hours, … )
Sets the hours for the Date object, according to the Universal Coordinated Time (UTC). Optionally sets the minutes, seconds and milliseconds.
Parameter(s):
void : setUTCMilliseconds( Number milliseconds )
Sets the milliseconds for the Date object, according to the Universal Coordinated Time (UTC).
Parameter(s):
void : setUTCMinutes( Number minutes, … )
Sets the minutes for the Date object, according to the Universal Coordinated Time (UTC). Optionally sets the seconds and milliseconds.
Parameter(s):
void : setUTCMonth( Number month, … )
Sets the month of the year for the Date object, according to the Universal Coordinated Time (UTC). Optionally sets the date.
Parameter(s):
void : setUTCSeconds( Number seconds, … )
Sets the seconds for the Date object, according to the Universal Coordinated Time (UTC). Optionally sets the milliseconds.
Parameter(s):
void : setYear( Number year, … )
Sets the year for the Date object. Optionally sets the month and date.
Parameter(s):
year
is a two digit number, like 91, it will be perceived as 1991. To set a year before 1900 or after 1999, use four digits.Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time) oDate.setYear( 2003 ); print( oDate.toString() ); //Fri Aug 15 2003 12:30:00 GMT-0600 (Mountain Daylight Time)
See Also:
String : toDateString()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toDateString() ); //Mon Aug 15 2005
String : toISOString()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toISOString() ); //2005-08-15T18:30:00.000Z
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toJSON() ); //2005-08-15T18:30:00.000Z
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toLocaleDateString() ); //Monday, August 15, 2005
String : toLocaleString()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toLocaleString() ); //Monday, August 15, 2005 12:30:00
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toLocaleTimeString() ); //12:30:00
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toString() ); //Mon Aug 15 2005 12:30:00 GMT-0600 (Mountain Daylight Time)
String : toTimeString()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toTimeString() ); //12:30:00 GMT-0600 (Mountain Daylight Time)
String : toUTCString()
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toUTCString() ); //Mon, 15 Aug 2005 18:30:00 GMT
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.valueOf() ); //1124130600000
See Also:
String : toGMTString()
Deprecated
Exists only to keep old code working. Do not use in new code. Use toUTCString() instead.
Return Value:
Example:
var oDate = new Date( 2005, 7, 15, 12, 30 ); print( oDate.toGMTString() ); //Mon, 15 Aug 2005 18:30:00 GMT