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.
The constructor property identifies the function used to create the Date object’s prototype.
The syntax for this property is:
Date.constructor
The prototype property is used to add new methods and properties to the Date object.
The syntax for this property is:
Date.prototype.methodDate.prototype.property
Methods
This section describes the Date object methods.
The getDate method returns the Date object’s day of the month value using local time.
The syntax for this method is:
date.getDate()
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()
The getFullYear method returns the Date object’s four-digit year value using local time.
The syntax for this method is:
date.getFullYear()
The getHours method returns the Date object’s hour value using local time.
The syntax for this method is:
date.getHours()
The getMilliseconds method returns the Date object’s milliseconds value using local time.
The syntax for this method is:
date.getMilliseconds()
The getMinutes method returns the Date object’s minutes value using local time.
The syntax for this method is:
date.getMinutes()
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()
The getSeconds method returns the Date object’s seconds value using local time.
The syntax for this method is:
date.getSeconds()
The getTime method returns the Date object’s date and time in milliseconds.
The syntax for this method is:
date.getTime()
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()
The getUTCDate method returns the Date object’s day of the month value using UTC.
The syntax for this method is:
date.getUTCDate()
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()
The getUTCFullYear method returns the Date object’s four-digit year value using UTC.
The syntax for this method is:
date.getUTCFullYear()
The getUTCHours method returns the Date object’s hour value using UTC.
The syntax for this method is:
date.getUTCHours()
The getUTCMilliseconds method returns the Date object’s milliseconds value using UTC.
The syntax for this method is:
date.getUTCMilliseconds()
The getUTCMinutes method returns the Date object’s minutes value using UTC.
The syntax for this method is:
date.getUTCMinutes()
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()
The getUTCSeconds method returns the Date object’s seconds value using UTC.
The syntax for this method is:
date.getUTCSeconds()
The parse method converts the string representation of a date and time into milliseconds.
The syntax for this method is:
Date.parse(date)
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)
The setFullYear method sets the Date object’s year value using local time.
The syntax for this method is:
date.setFullYear(year)
The setHours method sets the Date object’s hour value using local time.
The syntax for this method is:
date.setHours(hours)
The setMilliseconds method sets the Date object’s milliseconds value using local time.
The syntax for this method is:
date.setMilliseconds(milliseconds)
The setMinutes method sets the Date object’s minutes value using local time.
The syntax for this method is:
date.setMinutes(minutes)
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)
The setSeconds method sets the Date object’s seconds value using local time.
The syntax for this method is:
date.setSeconds(seconds)
The setTime method sets the Date object’s date and time in milliseconds.
The syntax for this method is:
date.setTime(milliseconds)
The setUTCDate method sets the Date object’s day of the month value using UTC.
The syntax for this method is:
date.setUTCDate(day)
The setUTCFullYear method sets the Date object’s four-digit year value using UTC.
The syntax for this method is:
date.setUTCFullYear(year)
The setUTCHours method sets the Date object’s hour value using UTC.
The syntax for this method is:
date.setUTCHours(hours)
The setUTCMilliseconds() sets the Date object’s milliseconds value using UTC.
The syntax for this method is:
date.setUTCMilliseconds(milliseconds)
The setUTCMinutes method sets the Date object’s minutes value using UTC.
The syntax for this method is:
date.setUTCMinutes(minutes)
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)
The setUTCSeconds method sets the Date object’s seconds value using universal time.
The syntax for this method is:
date.setUTCSeconds(seconds)
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()
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()
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()
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()
The toString method returns a string representation of the Date object in the local time zone.
The syntax for this method is:
date.toString()
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()
The toUTCString method converts the Date object to a string using the UTC.
The syntax for this method is:
date.toUTCString()
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)
The valueOf method returns a millisecond representation the Date object.
The syntax for this method is:
date.valueOf()