JS Built-ins
← Date27 / 120
DategetMonthbeginner

getMonth() β€” December is 11

πŸ“– Usage Example
const d = new Date(2024, 5, 15)  // June
d.getMonth()  // β†’ 5
// 0=Jan, 11=Dec

Use getMonth() to retrieve the zero-indexed month (0 = January through 11 = December) of a Date in local time.

Date.prototype.getMonth()

December has month index 11 (the last month in the 0-indexed system).

Challenge: Verify that new Date(2024, 11, 25).getMonth() returns 11.

πŸ’‘ Hints (1)
  • β€’ December is the 12th month, but its 0-indexed value is 11