Javascript Reference - JavaScript Date Reference








The Date object is used to work with dates and times.

Date Object Properties

Property Description
constructor Created the Date object
prototype Add properties and methods to an object

Date Object Methods

Method Description
getDate() Returns the day of the month in int type from 1-31
getDay() Returns the day of the week from 0-6
getFullYear() Returns the year in four digits
getHours() Returns the hour and the value is from 0-23
getMilliseconds() Returns the milliseconds and the value is from 0-999
getMinutes() Returns the minutes and the value is from 0-59
getMonth() Returns the month whose value is from 0-11
getSeconds() Returns the seconds whose value is from 0-59
getTime() Returns the number of milliseconds since midnight Jan 1, 1970
getTimezoneOffset() Returns the time difference between UTC time and local time in minutes
getUTCDate() Returns the day of the month, according to universal time, value from 1-31
getUTCDay() Returns the day of the week, according to universal time, value from 0-6
getUTCFullYear() Returns the year, according to universal time in four digits
getUTCHours() Returns the hour, according to universal time, value from 0-23
getUTCMilliseconds() Returns the milliseconds, according to universal time, value from 0-999
getUTCMinutes() Returns the minutes, according to universal time, value from 0-59
getUTCMonth() Returns the month, according to universal time, value from 0-11
getUTCSeconds() Returns the seconds, according to universal time, value from 0-59
getYear() Deprecated. Use the getFullYear() method instead
parse() Parses a date string and returns the number of milliseconds since January 1, 1970
setDate() Sets the day of the month for a date object
setFullYear() Sets the year in four digits for a date object
setHours() Sets the hour of a date object
setMilliseconds() Sets the milliseconds of a date object
setMinutes() Set the minutes for a date object
setMonth() Sets the month for a date object
setSeconds() Sets the seconds for a date object
setTime() Sets a date to a number of milliseconds after/before January 1, 1970
setUTCDate() Sets the day of the month, according to universal time
setUTCFullYear() Sets the year in four digits, according to universal time (four digits)
setUTCHours() Sets the hour, according to universal time
setUTCMilliseconds() Sets the milliseconds, according to universal time
setUTCMinutes() Set the minutes, according to universal time
setUTCMonth() Sets the month, according to universal time
setUTCSeconds() Set the seconds, according to universal time
setYear() Deprecated. Use the setFullYear() method instead
toDateString() Converts the date into a readable string for date part
toGMTString() Deprecated. Use the toUTCString() method instead
toISOString() Convert the date to a string using the ISO standard format
toJSON() Convert the date to a string in a JSON date format
toLocaleDateString() Convert the date portion of a Date object to a string using current locale
toLocaleTimeString() Convert the time portion of a Date object to a string using locale conventions
toLocaleString() Convert a Date object to a string using locale conventions
toString() Convert a Date object to a string
toTimeString() Convert the time part of a Date object to a string
toUTCString() Convert a Date object to a string according to universal time
UTC() Create date from the number of milliseconds since midnight of January 1, 1970, according to UTC time
valueOf() Convert date to its primitive value