Adobe InDesign CS5.5 Server (7.5) Object Model JS: Date

InDesign Server CS5.5

Class

Date

 A date/time object.

QuickLinks

Date, UTC, getDate, getDay, getFullYear, getHours, getMilliseconds, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getUTCDate, getUTCDay, getUTCFullYear, getUTCHours, getUTCMilliseconds, getUTCMinutes, getUTCMonth, getUTCSeconds, getYear, parse, setDate, setFullYear, setHours, setMilliseconds, setMinutes, setMonth, setSeconds, setTime, setUTCDate, setUTCFullYear, setUTCHours, setUTCMilliseconds, setUTCMinutes, setUTCMonth, setUTCSeconds, setYear, toDateString, toGMTString, toLocaleDateString, toLocaleString, toLocaleTimeString, toSource, toString, toTimeString, toUTCString, valueOf

Methods

Constructor

Date Date (year: number[, month: number=0][, day: number=0][, hours: number=0][, min: number=0][, sec: number=0][, ms: number=0])
Returns a new Date object holding the current date and time.
If parameters are supplied, returns a new Date object holding the supplied date and time.

ParameterTypeDescription
yearnumberThe year expressed in four digits.
monthnumber (range: 0 - 11)An integer value from 0 (Jan) to 11 (Dec). (default: 0) (Optional)
daynumber (range: 1 - 31)An integer value from 1 to 31, If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
hoursnumber (range: 0 - 23)An integer value from 0 (midnight) to 23 (11 PM). If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
minnumber (range: 0 - 59)An integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
secnumber (range: 0 - 59)An Integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
msnumber (range: 0 - 999)An integer value from 0 to 999. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)

Example new Date()
new Date (2006, 9, 25, 15, 30)

Class

Date UTC (year: number[, month: number=0][, day: number=0][, hours: number=0][, min: number=0][, sec: number=0][, ms: number=0])
Returns the number of milliseconds between midnight January 1, 1970, UTC, and the specified time.

ParameterTypeDescription
yearnumberThe year expressed in four digits, for example, 2001.
To indicate for a year from 1900 to 1999, you can specify a value from 0 to 99.
monthnumber (range: 0 - 11)An integer value from 0 (Jan) to 11 (Dec). (default: 0) (Optional)
daynumber (range: 1 - 31)An integer value from 1 to 31, If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
hoursnumber (range: 0 - 23)An integer value from 0 (midnight) to 23 (11 PM). If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
minnumber (range: 0 - 59)An integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
secnumber (range: 0 - 59)An Integer value from 0 to 59. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)
msnumber (range: 0 - 999)An integer value from 0 to 999. If this argument is not supplied, its value is set to 0. (default: 0) (Optional)

ExampleDate.UTC(year , month, date, hour, min, sec, ms)

Date parse (text: string)
Parses a string, returning a new Date object. The string should be similar to the string returned bt toString().

ParameterTypeDescription
textstringThe string to parse.

Instances

number getDate ()
Returns the day of the month of the specified Date object in local time. Range: 1 - 31

Exampledate.getDate()

number getDay ()
Returns the day of the week for the specified Date object in local time.
This is an integer from 0 (Sunday) to 6 (Saturday). Returns the day of the week for date. Range: 0 - 6

Exampledate.getDay()

number getFullYear ()
Returns the four digit year of the specified Date object in local time.

Exampledate.getFullYear()

number getHours ()
Returns the hour of the specified Date object in local time. Range: 0 - 23

Exampledate.getHours()

number getMilliseconds ()
Returns the milliseconds of the specified Date object in local time. Range: 0 - 999

Exampledate.getMilliseconds()

number getMinutes ()
Returns the minutes of the specified Date object in local time. Range: 0 - 59

Exampledate.getMinutes()

number getMonth ()
Returns the month of the specified Date object in local time. Range: 0 - 11

Exampledate.getMonth()

number getSeconds ()
Returns the seconds of the specified Date object in local time. Range: 0 - 59

Exampledate.getSeconds()

number getTime ()
Returns the number of milliseconds since midnight January 1,1970 UTC for the specified Date object.

Exampledate.getTime()

number getTimezoneOffset ()
Returns the difference in minutes between the computer's local time and UTC.

Exampledate.getTimezoneOffset()

number getUTCDate ()
Returns the day of the month of the specified Date object according to UTC. Range: 1 - 31

Exampledate.getUTCDate()

number getUTCDay ()
Returns the day of the week for the specified Date object according to UTC. Range: 0 - 6

Exampledate.getUTCDay()

number getUTCFullYear ()
Returns the four digit year of the specified Date object according to UTC.

Exampledate.getUTCFullYear()

number getUTCHours ()
Returns the hour of the specified Date object according to UTC. Range: 0 - 23

Exampledate.getUTCHours()

number getUTCMilliseconds ()
Returns the milliseconds of the specified Date object according to UTC. Range: 0 - 999

Exampledate.getUTCMilliseconds()

number getUTCMinutes ()
Returns the minutes of the specified Date object according to UTC. Range: 0 - 59

Exampledate.getUTCMinutes()

number getUTCMonth ()
Returns the month of the specified Date object according to UTC. Range: 0 - 11

Exampledate.getUTCMonth()

number getUTCSeconds ()
Returns the seconds of the specified Date object according to UTC. Range: 0 - 59

Exampledate.getUTCSeconds()

number getYear ()
Returns the year of the specified Date object, as a difference from 1900, in local time.

Exampledate.getYear()

number setDate (date: number)
Sets the day of the month of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
datenumber (range: 1 - 31)An integer from 1 to 31 indicating the day of the month.

Exampledate.setDate(date)

number setFullYear (year: number)
Sets the year of a specified Date object according to local time.
This method can also set month and date if those arguments are specified. Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
yearnumberA four-digit integer value indicating the year to set.

Exampledate.setFullYear(year, month, date)

number setHours (hour: number)
Sets the hours of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
hournumber (range: 0 - 23)An integer value from 0 (midnight) to 23 (11 PM).

Exampledate.setHours(hour)

number setMilliseconds (ms: number)
Sets the milliseconds of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
msnumber (range: 0 - 999)An integer value from 0 to 999.

Exampledate.setMilliseconds(ms)

number setMinutes (minutes: number)
Sets the minutes of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
minutesnumber (range: 0 - 59)An integer value from 0 to 59.

Exampledate.setMinutes(minutes)

number setMonth (month: number)
Sets the month of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
monthnumber (range: 0 - 11)An integer value from 0 (Jan) to 11 (Dec).

Exampledate.setMonth(month)

number setSeconds (seconds: number)
Sets the seconds of a specified Date object according to local time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970.

ParameterTypeDescription
secondsnumber (range: 0 - 59)An integer value from 0 to 59.

Exampledate.setSeconds(seconds)

number setTime (ms: number)
Sets the date of a specified Date object in milliseconds since midnight, January 1, 1970.
Returns the value of ms.

ParameterTypeDescription
msnumberAn integer indicating the number of milliseconds between the date set and midnight, January 1, 1970.

Exampledate.setTime(ms)

number setUTCDate (date: number)
Sets the date of a specified Date object according to universal time.
Returns the number of milliseconds between the new date and midnight, January 1, 1970 in UTC time.

ParameterTypeDescription
datenumber (range: 1 - 31)An integer from 1 to 31 indicating the day of the month.

Exampledate.setUTCDate(date)

number setUTCFullYear (year: number)
Sets the year of a specified Date object according to UTC, can also set the month and date.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
yearnumberThe year expressed in four digits.

Exampledate.setUTCFullYear(year, month, date)

number setUTCHours (hours: number)
Sets the hours of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
hoursnumber (range: 0 - 23)An integer value from 0 (midnight) to 23 (11 PM) indicating the hour to be set.

Exampledate.setUTCHours(hours)

number setUTCMilliseconds (ms: number)
Sets the milliseconds of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
msnumber (range: 0 - 999)An integer value in the range of 0 to 999 indicating the number of milliseconds to set.

Exampledate.setUTCMilliseconds(ms)

number setUTCMinutes (min: number)
Sets the minutes of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
minnumber (range: 0 - 59)An integer value in the range 0 to 59 indicating the number of minutes to be set.

Exampledate.setUTCMinutes(min)

number setUTCMonth (month: number)
Sets the month of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
monthnumber (range: 0 - 11)An integer value in the range 0 (Jan.) to 11 (Dec.) indicating the month to set.

Exampledate.setUTCMonth(month)

number setUTCSeconds (sec: number)
Sets the seconds of a specified Date object according to UTC.
Returns the number of milliseconds between the date set and midnight, January 1, 1970, in UTC.

ParameterTypeDescription
secnumber (range: 0 - 59)An integer value in the range 0 to 59 indicating the number of seconds to set.

Exampledate.setUTCSeconds(sec)

number setYear (year: number)
Sets the year of a specified Date object according to local time, as a difference between the current year and 1900.
Returns the number of milliseconds between the date set and midnight, January 1, 1970.

ParameterTypeDescription
yearnumberAn integer value indicating the year to set.
The method interprets a 1- or 2- digit value to mean the 1900s; for example, 13 is interpreted to mean 1913.

Exampledate.setYear(year, month, date)

string toDateString () Returns the date as a string.

string toGMTString () Returns the date and time adjusted to GMT (UTC) as a string.

string toLocaleDateString () Returns the date as a localized string.

string toLocaleString () Returns a string value representing the date and time stored in the Date object in human readable format (localized).

string toLocaleTimeString () Returns the time as a localized string.

string toSource ()
Creates a string representation of this object that can be fed back to eval() to re-create an object. Works only with built-in classes.

string toString ()
Returns a string value representing the date and time stored in the Date object in human readable format.
Returns the following string is an example of the format returned by this method: Mon Aug 13, 10:54:21 GMT-0700 2001.

Exampledate.toString()

string toTimeString () Returns the time as a string.

string toUTCString () Returns the date and time adjusted to UTC as a string.

number valueOf ()
The valueOf() method returns the number of milliseconds that have passed since midnight, Returns an integer.

Element of

$.buildDate

Asset.date

BookContent.date

Change.date

DocumentEvent.timeStamp

Event.timeStamp

File.created

File.modified

Folder.created

Folder.modified

IdleEvent.timeStamp

ImportExportEvent.timeStamp

Link.date

LinkMetadata.creationDate

LinkMetadata.modificationDate

MetadataPreference.creationDate

MetadataPreference.modificationDate

MutationEvent.timeStamp

Note.creationDate

Note.modificationDate

PrintEvent.timeStamp

Return

Date Date.Date (year: number[, month: number=0][, day: number=0][, hours: number=0][, min: number=0][, sec: number=0][, ms: number=0])

Date Date.UTC (year: number[, month: number=0][, day: number=0][, hours: number=0][, min: number=0][, sec: number=0][, ms: number=0])

Date Date.parse (text: string)

Jongware, 28-Apr-2012 v3.0.3iContents :: Index