JavaScripture
Contribute via GitHub Feedback

Date : Object

An object that represents a date and time. Internally the time is stored as the number of milliseconds since 01 January, 1970 UTC. Use new Date() to get a Date for the current time or Date.now() to get the current time in milliseconds since 01 January, 1970 UTC.

Date() : String

Returns a string representation of the current date and time.

Example:

Run

Results:

 

Constructors

new Date() : Date

Returns a new Date object that represents the current date and time.

Example:

Run

Results:

 

new Date(year : Number, month : Number, [date = 1 : Number, [hours = 0 : Number, [minutes = 0 : Number, [seconds = 0 : Number, [milliseconds = 0 : Number]]]]]) : Date

Returns a new Date object that represents the specified date and time. month 0 is January, 1 is February, etc. date is the calendar day, starting with 1 and will be at most 31.

Example:

Run

Results:

 

new Date(millisecondsSince1970 : Number) : Date

Returns a new Date object that is the specified number of milliseconds from 01 January, 1970 UTC.

Example:

Run

Results:

 

new Date(string : String) : Date

Parses string and returns a new Date object representing the specified date and time. See also Date.parse(string).

Example:

Run

Results:

 

Instance Methods

getDate() : Number

Returns the date of this in local time. Date is the calendar day, starting with 1 and will be at most 31.

Example:

Run

Results:

 

getDay() : Number

Returns the day of the week of this in local time. 0 = Sunday, 1 = Monday, 2 = Tuesday, etc.

Example:

Run

Results:

 

getFullYear() : Number

Returns the year of this in local time.

Example:

Run

Results:

 

getHours() : Number

Returns the hours of this in local time.

Example:

Run

Results:

 

getMilliseconds() : Number

Returns the milliseconds of this in local time.

Example:

Run

Results:

 

getMinutes() : Number

Returns the minutes of this in local time.

Example:

Run

Results:

 

getMonth() : Number

Returns the month of this in local time. 0 is January, 1 is February, etc.

Example:

Run

Results:

 

getSeconds() : Number

Returns the seconds of this in local time.

Example:

Run

Results:

 

getTime() : Number

Returns the number of milliseconds since 01 January, 1970 for this. See also valueOf().

Example:

Run

Results:

 

getTimezoneOffset() : Number

Returns the number of minutes between local time and UTC time.

Example:

Run

Results:

 

getUTCDate() : Number

Returns the date of this in UTC time. Date is the calendar day, starting with 1 and will be at most 31.

Example:

Run

Results:

 

getUTCDay() : Number

Returns the day of the week of this in UTC time. 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday.

Example:

Run

Results:

 

getUTCFullYear() : Number

Returns the year of this in UTC time.

Example:

Run

Results:

 

getUTCHours() : Number

Returns the hours of this in UTC time.

Example:

Run

Results:

 

getUTCMilliseconds() : Number

Returns the milliseconds of this in UTC time.

Example:

Run

Results:

 

getUTCMinutes() : Number

Returns the minutes of this in UTC time.

Example:

Run

Results:

 

getUTCMonth() : Number

Returns the month of this in UTC time. 0 is January, 1 is February, etc.

Example:

Run

Results:

 

getUTCSeconds() : Number

Returns the seconds of this in UTC time.

Example:

Run

Results:

 

setDate(date : Number) : Number

Sets the date of this. The other time components remain unchanged.

Example:

Run

Results:

 

setFullYear(year : Number, [month : Number, [date : Number]]) : Number

Sets the year (and optionally month and date) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setHours(hours : Number, [minutes : Number, [seconds : Number, [milliseconds : Number]]]) : Number

Sets the number of hours (and optionally minutes, seconds and milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setMilliseconds(milliseconds : Number) : Number

Sets the number of milliseconds of this. The other time components remain unchanged. Returns the time value of this.

Example:

Run

Results:

 

setMinutes(minutes : Number, [seconds : Number, [milliseconds : Number]]) : Number

Sets the number of minutes (and optionally seconds and milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setMonth(month : Number, [date : Number]) : Number

Sets the month (and optionally date) of this. Month 0 is January, 1 is February, etc. The other time components remain unchanged.

Example:

Run

Results:

 

setSeconds(seconds : Number, [milliseconds : Number]) : Number

Sets the number of seconds (and optionally milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setTime(millisecondsSince1970 : Number) : Number

Set this date to be the specified number of milliseconds from 01 January, 1970 UTC.

Example:

Run

Results:

 

setUTCDate(date : Number) : Number

Sets the date of this. The other time components remain unchanged.

Example:

Run

Results:

 

setUTCFullYear(year : Number, [month : Number, [date : Number]]) : Number

Sets the year (and optionally month and date) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setUTCHours(hours : Number, [minutes : Number, [seconds : Number, [milliseconds : Number]]]) : Number

Sets the number of hours (and optionally minutes, seconds and milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setUTCMilliseconds(milliseconds : Number) : Number

Sets the number of milliseconds of this. The other time components remain unchanged. Returns the time value of this.

Example:

Run

Results:

 

setUTCMinutes(minutes : Number, [seconds : Number, [milliseconds : Number]]) : Number

Sets the number of minutes (and optionally seconds and milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

setUTCMonth(month : Number, [date : Number]) : Number

Sets the month (and optionally date) of this. Month 0 is January, 1 is February, etc. The other time components remain unchanged.

Example:

Run

Results:

 

setUTCSeconds(seconds : Number, [milliseconds : Number]) : Number

Sets the number of seconds (and optionally milliseconds) of this. The other time components remain unchanged.

Example:

Run

Results:

 

toDateString() : String

Returns a string representing the date portion of this.

Example:

Run

Results:

 

toISOString() : String

Returns a string representation if this in ISO 8601 format.

Example:

Run

Results:

 

toJSON() : String

Returns a string representation of this suitable for storage in JSON.

Example:

Run

Results:

 

toLocaleDateString() : String

Returns a human readable string of the date portion of this in local time.

Example:

Run

Results:

 

toLocaleString() : String

Returns a human readable string of this in the local time.

Example:

Run

Results:

 

toLocaleTimeString() : String

Returns a human readable string of the time potion of this in local time.

Example:

Run

Results:

 

toTimeString() : String

Returns a string representing the time portion of this.

Example:

Run

Results:

 

toUTCString() : String

Returns a human readable string of this in UTC.

Example:

Run

Results:

 

valueOf() : Number

Returns the number of milliseconds since 01 January, 1970 UTC for this. You can also obtain the value by using the date in a number context such as +date. If you need the value of the current time, use Date.now() to avoid the cost of creating a Date object. See also getTime().

Example:

Run

Results:

 

Date Methods

now() : Number

Returns the number of milliseconds from 01 January, 1970 of the current time in UTC.

Example:

Run

Results:

 

parse(string : String) : Number

Parses string into a date and returns the number of milliseconds this date is from 01 January, 1970 UTC. Use new Date(string) to get a Date object from a string.

Example:

Run

Results:

 

UTC(year : Number, month : Number, [date = 1 : Number, [hour = 0 : Number, [minutes = 0 : Number, [seconds = 0 : Number, [milliseconds = 0 : Number]]]]]) : Number

Returns the number of milliseconds fom 01 January, 1970 UTC of the specified date and time in UTC. month 0 is January, 1 is February, etc. date is the calendar day, starting with 1 and will be at most 31.

Example:

Run

Results: