Date

The Date object is used for storing and retrieving dates and times.

Syntax

The syntax for this object is:

new Date()
//Or
new Date(millisecondsA)
//Or
new Date(string)
//Or
new Date(year, month, day, hours, minutes, seconds, millisecondsB)

Where:

millisecondsA represents the number of milliseconds between midnight January 1, 1970 and the desired date.

string specifies the date as a string.

year specifies the year (using a four-digit format.)

month specifies the month as an integer value where 0 represents January and 11 represents December.

day specifies the day of the month as an integer value between 1 and 31. (Optional)

hours specifies hours as an integer value where 0 represents midnight and 23 represents 11pm. (Optional)

seconds specifies the seconds in a minute as integer values between 0 and 59. (Optional)

millisecondsB specifies milliseconds in a second as integer values between 0 and 999. (Optional)

Sample

<?xml version="1.0"?>
<!DOCTYPE vxml PUBLIC "-//Nuance/DTD VoiceXML 2.0//EN"
"http://voicexml.nuance.com/dtd/nuancevoicexml-2-0.dtd" >
<vxml version="2.0">
...
   <script>
     //Creating a new date object.
     var d = new Date(); 
     //Initializing variables using Date object methods.
     var hours = d.getHours(); 
     var minutes = d.getMinutes(); 
     var seconds = d.getSeconds(); 
   </script> 
   <form> 
     //Returning hours, minutes, and seconds.
     <block>
        The time is <value expr="hours"/> hours
        <value expr="minutes"/> minutes, and 
        <value expr="seconds"/> seconds. 
     </block> 
   </form> 
...
</vxml> 

Properties

This section describes the Date object properties.

constructor

The constructor property identifies the function used to create the Date object’s prototype.

The syntax for this property is:

Date.constructor

prototype

The prototype property is used to add new methods and properties to the Date object.

The syntax for this property is:

Date.prototype.method
Date.prototype.property

Methods

This section describes the Date object methods.

getDate()

The getDate method returns the Date object’s day of the month value using local time.

The syntax for this method is:

date.getDate()

getDay()

The getDay method returns the Date object’s day of the week value expressed as an integer, that is, 0 for Sunday to 6 for Saturday.

The syntax for this method is:

date.getDay()

getFullYear()

The getFullYear method returns the Date object’s four-digit year value using local time.

The syntax for this method is:

date.getFullYear()

getHours()

The getHours method returns the Date object’s hour value using local time.

The syntax for this method is:

date.getHours()

getMilliseconds()

The getMilliseconds method returns the Date object’s milliseconds value using local time.

The syntax for this method is:

date.getMilliseconds()

getMinutes()

The getMinutes method returns the Date object’s minutes value using local time.

The syntax for this method is:

date.getMinutes()

getMonth()

The getMonth method returns the Date object’s month value expressed as an integer, that is, 0 for January to 11 for December.

The syntax for this method is:

date.getMonth()

getSeconds()

The getSeconds method returns the Date object’s seconds value using local time.

The syntax for this method is:

date.getSeconds()

getTime()

The getTime method returns the Date object’s date and time in milliseconds.

The syntax for this method is:

date.getTime()

getTimeZoneOffSet()

The getTimeZoneOffSet method returns the Date object’s offset from Universal Time Conversion (UTC) to the local time in minutes.

The syntax for this method is:

date.getTimeZoneOffSet()

getUTCDate()

The getUTCDate method returns the Date object’s day of the month value using UTC.

The syntax for this method is:

date.getUTCDate()

getUTCDay()

The getUTCDay method returns the Date object’s day of the week value using UTC. Note that the day of the week value is expressed as an integer, that is, 0 for Sunday to 6 for Saturday.

The syntax for this method is:

date.getUTCDay()

getUTCFullYear()

The getUTCFullYear method returns the Date object’s four-digit year value using UTC.

The syntax for this method is:

date.getUTCFullYear()

getUTCHours()

The getUTCHours method returns the Date object’s hour value using UTC.

The syntax for this method is:

date.getUTCHours()

getUTCMilliseconds()

The getUTCMilliseconds method returns the Date object’s milliseconds value using UTC.

The syntax for this method is:

date.getUTCMilliseconds()

getUTCMinutes()

The getUTCMinutes method returns the Date object’s minutes value using UTC.

The syntax for this method is:

date.getUTCMinutes()

getUTCMonth()

The getUTCMonth method returns the Date object’s month value using UTC. Note that month values are expressed as integers, that is, 0 for January to 11 for December.

The syntax for this method is:

date.getUTCMonth()

getUTCSeconds()

The getUTCSeconds method returns the Date object’s seconds value using UTC.

The syntax for this method is:

date.getUTCSeconds()

parse()

The parse method converts the string representation of a date and time into milliseconds.

The syntax for this method is:

Date.parse(date)

setDate()

The setDate method sets the Date object’s day of the month value using local time.

The syntax for this method is:

date.setDate(day)

setFullYear()

The setFullYear method sets the Date object’s year value using local time.

The syntax for this method is:

date.setFullYear(year)

setHours()

The setHours method sets the Date object’s hour value using local time.

The syntax for this method is:

date.setHours(hours)

setMilliseconds()

The setMilliseconds method sets the Date object’s milliseconds value using local time.

The syntax for this method is:

date.setMilliseconds(milliseconds)

setMinutes()

The setMinutes method sets the Date object’s minutes value using local time.

The syntax for this method is:

date.setMinutes(minutes)

setMonth()

The setMonth method sets the Date object’s month value using local time. Note that month values are specified as integers, that is, 0 for January to 11 for December.

The syntax for this method is:

date.setMonth(month)

setSeconds()

The setSeconds method sets the Date object’s seconds value using local time.

The syntax for this method is:

date.setSeconds(seconds)

setTime()

The setTime method sets the Date object’s date and time in milliseconds.

The syntax for this method is:

date.setTime(milliseconds)

setUTCDate()

The setUTCDate method sets the Date object’s day of the month value using UTC.

The syntax for this method is:

date.setUTCDate(day)

setUTCFullYear()

The setUTCFullYear method sets the Date object’s four-digit year value using UTC.

The syntax for this method is:

date.setUTCFullYear(year)

setUTCHours()

The setUTCHours method sets the Date object’s hour value using UTC.

The syntax for this method is:

date.setUTCHours(hours)

setUTCMilliseconds()

The setUTCMilliseconds() sets the Date object’s milliseconds value using UTC.

The syntax for this method is:

date.setUTCMilliseconds(milliseconds)

setUTCMinutes()

The setUTCMinutes method sets the Date object’s minutes value using UTC.

The syntax for this method is:

date.setUTCMinutes(minutes)

setUTCMonth()

The setUTCMonth method sets the Date object’s month value using UTC. Note that month values are specified as integers, that is, 0 for January to 11 for December.

The syntax for this method is:

date.setUTCMonth(month)

setUTCSeconds()

The setUTCSeconds method sets the Date object’s seconds value using universal time.

The syntax for this method is:

date.setUTCSeconds(seconds)

toDateString()

The toDateString method returns a string representation of the Date object’s day of the month value using local time.

The syntax for this method is:

date.toDateString()

toLocaleDateString()

The toLocaleDateString method returns a string representation of the Date object’s date containing the month, day of the month, and year in local time.

The syntax for this method is:

date.toLocaleDateString()

toLocaleString()

The toLocaleString method converts a date to a string using the host environment's local time zone.

The syntax for this method is:

date.toLocaleString()

toLocaleTimeString()

The toLocaleTimeString method returns a string representation of the Date object’s time value, expressed in the local time zone and formatted according to the local host conventions.

The syntax for this method is:

date.toLocaleTimeString()

toString()

The toString method returns a string representation of the Date object in the local time zone.

The syntax for this method is:

date.toString()

toTimeString()

The toTimeString method returns a string representation of the Date object’s time value, expressed in the local time zone.

The syntax for this method is:

date.toTimeString()

toUTCString()

The toUTCString method converts the Date object to a string using the UTC.

The syntax for this method is:

date.toUTCString()

UTC()

The UTC method converts the Date object’s UTC date and time specification to milliseconds.

The syntax for this method is:

Date.UTC(year, month, day, hours, minutes, seconds, milliseconds)

valueOf()

The valueOf method returns a millisecond representation the Date object.

The syntax for this method is:

date.valueOf()