Date

Example

1

Description

Properties

Property Name Description
constructor function that created the Date object's prototype
prototype allows adding properties and methods to the object

Methods

Method Name Description Values
getDay() Returns the day of the week (from 0 to 6, Sunday being 0) of the Date.
getFullYear() Returns the four-digit year of the Date.
getHours() Returns the hour of the Date (from 0-23).
getMilliseconds() Returns the millisecond of the Date (from 0-999).
getMinutes() Returns the minute of the Date (from 0-59).
getMonth() Returns the month of the Date (from 0-11, January being 0).
getSeconds() Returns the seconds of the Date (from 0 to 59).
getTime() Returns the number of milliseconds from midnight, January 1, 1970 to the Date.
getTimezoneOffset() Returns the difference between Greenwich Mean Time (GMT) and local time in minutes.
getUTCDate() Returns the day of the month (from 1 to 31) for the specified date, in Coordinated Universal Time.
getUTCDay() Returns the day of the week (from 0 to 6, Sunday being 0) of the Date, in Coordinated Universal Time.
getUTCFullYear() Returns the four-digit year of the Date, in Coordinated Universal Time.
getUTCHours() Returns the hour of the Date (from 0-23), in Coordinated Universal Time.
getUTCMilliseconds() Returns the millisecond of the Date (from 0-999), in Coordinated Universal Time.
getUTCMinutes() Returns the minute of the Date (from 0-59), in Coordinated Universal Time.
getUTCMonth() Returns the month of the Date (from 0-11, January being 0), in Coordinated Universal Time.
getUTCSeconds() Returns the seconds of the Date (from 0 to 59), in Coordinated Universal Time.
getYear() Deprecated in favor of getFullYear().
parse() Parses a date string and returns the number of milliseconds elapsed from midnight, January 1, 1970 to that date.
setDate() Sets the day of the month (from 1-31).
setFullYear() Sets the four-digit year, and optionally the month (0-11) and day (1-31).
setHours() Sets the hour, and optionally the minute (0-59), second (0-59), and millisecond (0-999).
setMilliseconds() Sets the millisecond (from 0-999).
setMinutes() Sets the minute, and optionally the second (0-59) and millisecond (0-999).
setMonth() Sets the month (from 0-11) and optionally the day (1-31).
setSeconds() Sets the seconds (from 0-59) and optionally milliseconds (0-999).
setTime() Sets the Date based on the number of milliseconds since midnight, January 1, 1970.
setUTCDate() Sets the day of the month (from 1-31), in Coordinated Universal Time.
setUTCFullYear() Sets the four-digit year, in Coordinated Universal Time.
setUTCHours() Sets the hour, and optionally the minute (0-59), second (0-59), and millisecond (0-999), in Coordinated Universal Time.
setUTCMilliseconds() Sets the millisecond (from 0-999), in Coordinated Universal Time.
setUTCMinutes() Sets the minute, and optionally the second (0-59) and millisecond (0-999), in Coordinated Universal Time.
setUTCMonth() Sets the month (from 0-11) and optionally the day (1-31), in Coordinated Universal Time.
setUTCSeconds() Sets the seconds (from 0-59) and optionally milliseconds (0-999), in Coordinated Universal Time.
setYear() Deprecated in favor of setFullYear().
toDateString() Returns a String representation of the date.
toGMTString() Deprecated in favor of toUTCString().
toLocaleDateString() Returns a String representation of the date portion of the Date object using the system's locale.
toLocaleString() Returns a String representation of the Date using the system's locale.
toLocaleTimeString() Returns a String representation of the time portion of the Date object using the system's locale.
toString() Returns a String representation of the Date.
toTimeString() Returns a String representation of the time portion of the Date.
toUTCString() Returns a String representation of the Date in Coordinated Universal Time.
UTC() Returns the number of milliseconds from midnight, January 1, 1970 to the specified date in Coordinated Universal Time.
valueOf() Returns the primitive value of a Date object as the number of milliseconds since midnight, January 1, 1970 UTC.