Lets you work with dates and times.
![]() | Since Virtual Ticket, Job Manager, and Digital Storage Manager use separate date and time types, it is recommended that you use the XDate or XTime object instead of the Date object. |
Core object
Created by
The Date constructor:
new Date() ;
new Date( milliseconds );
new Date( dateString );
new Date( yr_num, mo_num, day_num__
[, hr_num, min_num, sec_num, ms_num] );
Parameters
Parameter | Description |
---|---|
milliseconds | Integer value representing the number of milliseconds since 1 January 1970 00:00:00. |
dateString | String value representing a date. The string should be in a format recognized by the Date.parse method. |
yr_num, mo_num, day_num | Integer values representing part of a date. As an integer value, the month is represented by 0 to 11 with 0 = January and 11 = December. |
hr_num, min_num,sec_num, ms_num | Integer values representing part of a date. |
Description
If you supply no arguments, the constructor creates a Date object for today's date and time according to local time. If you supply some arguments but not others, the missing arguments are set to 0. If you supply any arguments, you must supply at least the year, month, and day. You can omit the hours, minutes, seconds, and milliseconds.
The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day holds 86,400,000 milliseconds. The Date object range is -100,000,000 days to 100,000,000 days relative to 01 January, 1970 UTC.
The Date object provides uniform behavior across platforms.
The Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where MetaScript is executed.
For compatibility with millennium calculations (in other words, to take into account the year 2000), you should always specify the year in full; for example, use 1998, not 98. To assist you in specifying the complete year, MetaScript includes the methods getFullYear, setFullYear, getFullUTCYear, and setFullUTCYear.
The following example returns the time elapsed between timeA and timeB in milliseconds.
Property Summary
Property | Description |
---|---|
constructor | Specifies the function that creates an object's prototype. |
prototype | Allows the addition of properties to a Date object. |
Method Summary
Method | Description |
---|---|
Date.getDate | Returns the day of the month for the specified date according to local time. |
Date.getDay | Returns the day of the week for the specified date according to local time. |
Date.getFullYear | Returns the year of the specified date according to local time. |
Date.getHours | Returns the hour in the specified date according to local time. |
Date.getMilliseconds | Returns the number of milliseconds in the specified date according to local time. |
Date.getMinutes | Returns the minutes in the specified date according to local time. |
Date.getMonth | Returns the month in the specified date according to local time. |
Date.getSeconds | Returns the seconds in the specified date according to local time. |
Date.getTime | Returns the numeric value corresponding to the time for the specified date according to local time. |
Date.getTimezoneOffset | Returns the time-zone offset in minutes for the current locale. |
Date.getUTCDate | Returns the day (date) of the month in the specified date according to universal time. |
Date.getUTCDay | Returns the day of the week in the specified date according to universal time. |
Date.getUTCFullYear | Returns the year in the specified date according to universal time. |
Date.getUTCHours | Returns the hours in the specified date according to universal time. |
Date.getUTCMilliseconds | Returns the milliseconds in the specified date according to universal time. |
Date.getUTCMinutes | Returns the minutes in the specified date according to universal time. |
Date.getUTCMonth | Returns the month according in the specified date according to universal time. |
Date.getUTCSeconds | Returns the seconds in the specified date according to universal time. |
Date.getYear | Returns the year in the specified date according to local time. |
Date.parse | Returns the number of milliseconds in a date string since January 1, 1970, 00:00:00, local time. |
Date.setDate | Sets the day of the month for a specified date according to local time. |
Date.setFullYear | Sets the full year for a specified date according to local time. |
Date.setHours | Sets the hours for a specified date according to local time. |
Date.setMilliseconds | Sets the milliseconds for a specified date according to local time. |
Date.setMinutes | Sets the minutes for a specified date according to local time. |
Date.setMonth | Sets the month for a specified date according to local time. |
Date.setSeconds | Sets the seconds for a specified date according to local time. |
Date.setTime | Sets the value of a Date object according to local time. |
Date.setUTCDate | Sets the day of the month for a specified date according to universal time. |
Date.setUTCFullYear | Sets the full year for a specified date according to universal time. |
Date.setUTCHours | Sets the hour for a specified date according to universal time. |
Date.setUTCMilliseconds | Sets the milliseconds for a specified date according to universal time. |
Date.setUTCMinutes | Sets the minutes for a specified date according to universal time. |
Date.setUTCMonth | Sets the month for a specified date according to universal time. |
Date.setUTCSeconds | Sets the seconds for a specified date according to universal time. |
Date.setYear | Sets the year for a specified date according to local time. |
Date.toGMTString | Converts a date to a string, using the Internet GMT conventions. |
Date.toLocaleString | Converts a date to a string, using the current locale's conventions. |
Date.toSource | Returns an object literal representing the specified Date object; you can use this value to create a new object. Overrides the Object.toSource method. |
Date.toString | Returns a string representing the specified Date object. Overrides the Object.toString method. |
Date.toUTCString | Converts a date to a string, using the universal time convention. |
Date.UTC | Returns the milliseconds in a Date object since January 1, 1970, 00:00:00, universal time. |
Date.valueOf | Returns the primitive value of a Date object. Overrides the Object.valueOf method. |
In addition, this object inherits the Object.watch and Object.unwatch methods from Object.
Examples
The following examples show several ways to assign dates:
Labels












































