Quick Reference
This is a quick reference list of JavaScript date methods and properties with examples of how they are used.
- JavaScript – Date constructor PropertyThe Date constructor property returns the function that created the Date prototype.
- JavaScript – Date getDate() MethodThe Date getDate() method returns the day of the month (1 to 31) of a Date object.
- JavaScript – Date getDay() MethodThe 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() MethodThe Date getHours() method returns the hour (0 to 23) of a Date object: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
- JavaScript – Date getMilliseconds() MethodThe Date getMilliseconds() method returns the milliseconds (0 to 999) of a Date object.
- JavaScript – Date getFullYear() MethodThe Date getFullYear() method returns the full year (4 digits) of a Date object.
- JavaScript – Date getMinutes() MethodThe Date getMinutes() method returns the minutes (0 to 59) of a Date object.
- JavaScript – Date getMonth() MethodThe Date getMonth() method returns the month (0 to 11) of a Date object: January = 0, February = 1, March = 2 … December = 11.
- JavaScript – Date getSeconds() MethodThe Date getSeconds() method returns the seconds (0 to 59) of a Date object.
- JavaScript – Date getTime() MethodThe Date getTime() method returns the number of milliseconds since January 1, 1970 00:00:00.
- JavaScript – Date getTimezoneOffset() MethodThe Date getTimezoneOffset() method returns the difference between UTC time and local time in minutes.
- JavaScript – Date getUTCDate() MethodThe Date getUTCDate() method returns the day of the month (1 to 31) of a Date object, according to UTC.
- JavaScript – Date getUTCDay() MethodThe 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() MethodThe Date getUTCFullYear() method returns the full year (4 digits) of a Date object, according to UTC.
- JavaScript – Date getUTCHours() MethodThe 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() MethodThe Date getUTCMilliseconds() method returns the milliseconds (0 to 999) of a Date object, according to UTC.
- JavaScript – Date getUTCMinutes() MethodThe Date getUTCMinutes() method returns the minutes (0 to 59) of a Date object, according to UTC.
- JavaScript – Date getUTCMonth() MethodThe 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() MethodThe Date getUTCSeconds() method returns the seconds (0 to 59) of a Date object, according to UTC.
- JavaScript – Date now() MethodThe Date now() method returns the number of milliseconds since January 1, 1970 00:00:00.
- JavaScript – Date parse() MethodThe Date parse() method parses a date string and returns the number of milliseconds since January 1, 1970 00:00:00.
- JavaScript – Date.prototype PropertyThe Date.prototype() property allows you to add new properties and methods to the Date object.
- JavaScript – Date setDate() MethodThe Date setDate() method sets the day of the month (1 to 31) of a Date object.
- JavaScript – Date setFullYear() MethodThe Date setFullYear() method sets the full year (4 digits) of a date, and can also set the month and Date object.
- JavaScript – Date setHours() MethodThe Date getHours() method returns the hour (0 to 23) of a Date object: 12am = 0, 1am = 1, 2am = 2 … 11pm = 23.
- JavaScript – Date setMilliseconds() MethodThe Date setMilliseconds() method sets the milliseconds (0 to 999) of a Date object.
- JavaScript – Date setMinutes() MethodThe 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() MethodThe Date setMonth() method sets the month (0 to 11) of a Date object: January = 0, February = 1, March = 2 … December = 11.
- JavaScript – Date setSeconds() MethodThe Date setSeconds() method sets the seconds (0 to 59) of a Date object, and can also set the milliseconds.
- JavaScript – Date setTime() MethodThe 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() MethodThe 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() MethodThe Date setUTCDate() method sets the day of the month (1 to 31) of a Date object, according to UTC.
- JavaScript – Date setUTCHours() MethodThe 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() MethodThe Date setUTCMilliseconds() method sets the milliseconds (0 to 999) of a Date object, according to UTC.
- JavaScript – Date setUTCMinutes() MethodThe 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() MethodThe 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() MethodThe 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() MethodThe Date toDateString() method returns the date (not the time) of a Date object as a string.
- JavaScript – Date toISOString() MethodThe Date toISOString() method returns a Date object as a string, using the ISO standard format: YYYY-MM-DDTHH:mm:ss.sssZ.
- JavaScript – Date toJSON() MethodThe 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() MethodThe Date toLocaleDateString() method returns the date (not the time) of a Date object as a string, using locale conventions.
- JavaScript – Date toLocaleString() MethodThe Date toLocaleString() method returns a date and time as a string, using locale settings.
- JavaScript – Date toLocaleTimeString() MethodThe Date toLocaleTimeString() method returns the time portion of a Date object as a string, using locale conventions.
- JavaScript – Date toString() MethodThe Date toString() method returns a Date object as a string.
- JavaScript – Date toTimeString() MethodThe Date toTimeString() method returns the time portion of a Date object as a string.
- JavaScript – Date toUTCString() MethodThe Date toUTCString() method returns a Date object as a string, according to UTC.
- JavaScript – Date.UTC() MethodThe Date.UTC() method returns the number of milliseconds between a specified date and midnight of January 1, 1970, according to UTC.
- JavaScript – Date valueOf() MethodThe Date valueOf() method returns the primitive value of a Date object as the number of millisecond since midnight January 1, 1970 UTC.
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)
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.