getters

Date.prototype.getMonth

Returns the month of the date in LOCAL time as an integer from 0 (January) to 11 (December). This zero-based indexing is the single most common source of off-by-one date bugs in JavaScript.

date.getMonth()

Parameters

Parameter Purpose
() no arguments; returns 0-11
+1 add 1 for a human month number (1-12)

Examples

console.log(new Date('2026-07-19').getUTCMonth()); // 6

July is 6, not 7

console.log(new Date('2026-01-01').getUTCMonth()); // 0

January = 0

const m = new Date().getMonth() + 1; console.log(m); // human 1-12

convert to 1-based

const names=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; console.log(names[new Date('2026-07-19').getUTCMonth()]); // 'Jul'

index into a month array

Gotcha

getMonth returns 0-11, NOT 1-12 (January=0, December=11). Always add 1 before displaying a human month number.

Related

← All JS Date methods · Math methods · Cron syntax