CKTIS / JavaScript
Date.prototype.getMonth: local month index
getMonth returns the local month as a zero-based index from 0 for January through 11 for December.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
date.getMonth()date.getMonth() returns the local month index as a Number: 0 is January and 11 is December. Zero-based numbering is a common source of bugs; use a name array or Intl.DateTimeFormat for display rather than showing the raw value. getUTCMonth() provides the UTC field.
The method takes no arguments, does not mutate the date, and ignores extra arguments. It returns NaN for an invalid Date. A receiver without Date internal state, such as Date.prototype.getMonth.call({}), throws TypeError.
The time zone can change the month for instants near its boundary. The index matches the month argument used by Date constructors and setMonth, which normalizes values outside 0–11. The method has existed since ECMAScript 1.
Examples
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const date = new Date(2024, 10, 5, 12);
console.log(date.getMonth(), monthNames[date.getMonth()]);
date.setMonth(date.getMonth() + 2);
console.log(date.getFullYear(), date.getMonth(), monthNames[date.getMonth()]);
console.log(Number.isNaN(new Date(NaN).getMonth()));Result
10 Nov 2025 0 Jan true