Date - Overview

The Date object is used to represent a given date and time in a script. You must create a new Date object in the script before you can use the Date functions. There are four methods of assigning a new instance of a date

Method 1

In this instance myDate will be set to the current date and time on your PC, for example, " Wed 21 November 2001 13:20:10". This is the most commonly used method.

var myDate = new Date()

Method 2

In this instance myDate will be set to "31 January 2000 00:20:00", which is the number of milliseconds that have passed since Midnight 1/1/1970.

var myDate = new Date(949278000000)

Method 3

In this instance, the date and time is entered as a string. You may enter just the date if the time is not required.

var myDate = new Date("Wed 21 November 2001, 13:20:10")

Method 4

In this instance, the date and time is entered as individual values in the following order: Year, Month, Day, Hour, Minute. Each of the values can either be a number or a variable containing a number. In this example, the date is 31 Dec 2001 08:00:00 (

The month January is entered as the number 0 and the month December is 11.

var mydate = new Date(2001,11,31,8,0)

Get and Set Date functions

Once you have created a new Date object in your script, you can use Get actions to retrieve the current date set in the Date object

var date = myDate.getDate()

Alternatively, once you have created a new Date object in your script, you can use the Set actions to place a new date in the Date object

var setDate = myDate.setDate(10)

Date - Syntax information

Hierarchy:

Only the specific functions listed under the Functions: heading below can be used with Date objects:

Class Hierarchy:

Date

Hierarchy of objects in Opus

Functions:

Date.parse

Return the number of milliseconds since 1/1/1970

getDate

Return the day of the month

getDay

Return the day of the week

getFullYear

Return the year

getHours

Return the hour

getMilliseconds

Return the number of milliseconds

getMinutes

Return the minutes

getMonth

Return the month

getSeconds

Return the seconds

getTime

Return the number of milliseconds since 1/1/1970

getTimezoneOffset

Return the difference between local time zone and universal time in minutes

getUTCDate

Return the day of the month in universal time

getUTCDay

Return the day of the week in universal time

getUTCFullYear

Return the year in universal time

getUTCHours

Return the hour in universal time

getUTCMilliseconds

Return the number of milliseconds in universal time

getUTCMinutes

Return the minutes in universal time

getUTCMonth

Return the month in universal time

getUTCSeconds

Return the seconds in universal time

setDate

Set the day of the month

setFullYear

Sets the year

setHours

Sets the hour

setMilliseconds

Sets the number of milliseconds

setMinutes

Sets the minutes

setMonth

Sets the month

setSeconds

Sets the seconds

setTime

Sets the time since 1/1/1970 in milliseconds

setUTCDate

Sets the date in the month in universal time

setUTCFullYear

Sets the full year in universal time

setUTCHours

Sets the hour in universal time

setUTCMilliseconds

Sets the number of milliseconds in universal time

setUTCMinutes

Sets the number of minutes in universal time

setUTCMonth

Sets the month in universal time

setUTCSeconds

Sets the seconds in universal time

toGMTString

Converts the Date object to a string adjusted to GMT (Greenwich Mean Time)

toLocaleString

Converts the Date object to a string adjusted to local time zone

toString

Converts the Date object into a string

toUTCString

Converts the Date object into a string adjusted to universal time

valueOf

Return the value of the Date object as a number of milliseconds