- Tags: Date
- Categories: JavaScript Reference, JavaScript Resources, Reference
Quick Reference
This is a quick reference list of JavaScript date methods and properties with examples of how they are used.
JavaScript – Date constructor Property
The Date constructor property returns the function that created the Date prototype.
JavaScript – Date getDate() Method
The Date getDate() method returns the day of the month (1 to 31) of a Date object.
JavaScript – Date getDay() Method
The Date getDay() method returns the day of the week (0 to 6) of a Date object: Sunday = 0, Monday = 1, Tuesday = 2 … Saturday = 6.
JavaScript – Date getHours() Method
The Date getHours() method returns the hour (0 to 23) of a Date object: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
JavaScript – Date getMilliseconds() Method
The Date getMilliseconds() method returns the milliseconds (0 to 999) of a Date object.
JavaScript – Date getFullYear() Method
The Date getFullYear() method returns the full year (4 digits) of a Date object.
JavaScript – Date getMinutes() Method
The Date getMinutes() method returns the minutes (0 to 59) of a Date object.
JavaScript – Date getMonth() Method
The Date getMonth() method returns the month (0 to 11) of a Date object: January = 0, February = 1, March = 2 … December = 11.
JavaScript – Date getSeconds() Method
The Date getSeconds() method returns the seconds (0 to 59) of a Date object.
JavaScript – Date getTime() Method
The Date getTime() method returns the number of milliseconds since January 1, 1970 00:00:00.
JavaScript – Date getTimezoneOffset() Method
The Date getTimezoneOffset() method returns the difference between UTC time and local time in minutes.
JavaScript – Date getUTCDate() Method
The Date getUTCDate() method returns the day of the month (1 to 31) of a Date object, according to UTC.
JavaScript – Date getUTCDay() Method
The Date getUTCDay() method returns the day of the week (0 to 6) of a Date object, according to UTC: Sunday = 0, Monday = 1 … Saturday = 6.
JavaScript – Date getUTCFullYear() Method
The Date getUTCFullYear() method returns the full year (4 digits) of a Date object, according to UTC.
JavaScript – Date getUTCHours() Method
The Date getUTCHours() method returns the hour (0 to 23) of a Date object, according to UTC: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
JavaScript – Date getUTCMilliseconds() Method
The Date getUTCMilliseconds() method returns the milliseconds (0 to 999) of a Date object, according to UTC.
JavaScript – Date getUTCMinutes() Method
The Date getUTCMinutes() method returns the minutes (0 to 59) of a Date object, according to UTC.
JavaScript – Date getUTCMonth() Method
The Date getUTCMonth() method returns the month (0 to 11) of a Date object, according to UTC: January = 0, February = 1, March = 2 … December = 11.
JavaScript – Date getUTCSeconds() Method
The Date getUTCSeconds() method returns the seconds (0 to 59) of a Date object, according to UTC.
JavaScript – Date now() Method
The Date now() method returns the number of milliseconds since January 1, 1970 00:00:00.
JavaScript – Date parse() Method
The Date parse() method parses a date string and returns the number of milliseconds since January 1, 1970 00:00:00.
JavaScript – Date.prototype Property
The Date.prototype() property allows you to add new properties and methods to the Date object.
JavaScript – Date setDate() Method
The Date setDate() method sets the day of the month (1 to 31) of a Date object.
JavaScript – Date setFullYear() Method
The Date setFullYear() method sets the full year (4 digits) of a date, and can also set the month and Date object.
JavaScript – Date setHours() Method
The Date getHours() method returns the hour (0 to 23) of a Date object: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
JavaScript – Date setMilliseconds() Method
The Date setMilliseconds() method sets the milliseconds (0 to 999) of a Date object.
JavaScript – Date setMinutes() Method
The Date setMinutes() method sets the minutes (0 to 59) of a Date object, and can also be used to set the seconds and milliseconds.
JavaScript – Date setMonth() Method
The Date setMonth() method sets the month (0 to 11) of a Date object: January = 0, February = 1, March = 2 … December = 11.
JavaScript – Date setSeconds() Method
The Date setSeconds() method sets the seconds (0 to 59) of a Date object, and can also set the milliseconds.
JavaScript – Date setTime() Method
The Date setTime() method sets a date and time by adding or subtracting a specified number of milliseconds to or from midnight January 1, 1970.
JavaScript – Date setUTCFullYear() Method
The Date setUTCFullYear() method sets the full year (4 digits) of a Date object, according to UTC, and can also set the month and day.
JavaScript – Date setUTCDate() Method
The Date setUTCDate() method sets the day of the month (1 to 31) of a Date object, according to UTC.
JavaScript – Date setUTCHours() Method
The Date getUTCHours() method returns the hour (0 to 23) of a Date object, according to UTC: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
JavaScript – Date setUTCMilliseconds() Method
The Date setUTCMilliseconds() method sets the milliseconds (0 to 999) of a Date object, according to UTC.
JavaScript – Date setUTCMinutes() Method
The Date setUTCMinutes() method sets the minutes (0 to 59) of a date, according to UTC, and can also set the seconds and milliseconds.
JavaScript – Date setUTCMonth() Method
The Date setUTCMonth() method sets the month (0 to 11) of a Date object, according to UTC: January = 0, February = 1, March = 2 … December = 11.
JavaScript – Date setUTCSeconds() Method
The Date setUTCSeconds() method sets the seconds (0 to 59) of a Date object, according to UTC, and can also set the milliseconds.
JavaScript – Date toDateString() Method
The Date toDateString() method returns the date (not the time) of a Date object as a string.
JavaScript – Date toISOString() Method
The Date toISOString() method returns a Date object as a string, using the ISO standard format: YYYY-MM-DDTHH:mm:ss.sssZ.
JavaScript – Date toJSON() Method
The Date toJSON() method returns a Date object as a string, formatted as a JSON date, using the format: YYYY-MM-DDTHH:mm:ss.sssZ.
JavaScript – Date toLocaleDateString() Method
The Date toLocaleDateString() method returns the date (not the time) of a Date object as a string, using locale conventions.
JavaScript – Date toLocaleString() Method
The Date toLocaleString() method returns a date and time as a string, using locale settings.
JavaScript – Date toLocaleTimeString() Method
The Date toLocaleTimeString() method returns the time portion of a Date object as a string, using locale conventions.
JavaScript – Date toString() Method
The Date toString() method returns a Date object as a string.
JavaScript – Date toTimeString() Method
The Date toTimeString() method returns the time portion of a Date object as a string.
JavaScript – Date toUTCString() Method
The Date toUTCString() method returns a Date object as a string, according to UTC.
JavaScript – Date.UTC() Method
The Date.UTC() method returns the number of milliseconds between a specified date and midnight of January 1, 1970, according to UTC.
JavaScript – Date valueOf() Method
The Date valueOf() method returns the primitive value of a Date object as the number of millisecond since midnight January 1, 1970 UTC.
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
JavaScript Books
All are affiliate links. Thank you for your support!
JAVASCRIPT NOTES:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.