JavaScript Date getMonth() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.prototype.getMonth() returns the month for this date as a zero-based integer 0–11 in local time (MDN). 0 is January; 11 is December. It is read-only and does not change the Date.

Remember
date.getMonth()

0  = January
1  = February
…
11 = December

→ integer 0 … 11
→ NaN if the Date is invalid

getMonth()    → local month index
getUTCMonth() → UTC month index

Syntax

Call date.getMonth. Start with this line.

JavaScript
date.getMonth()
CallWhat it does
date.getMonth()Primary signature.
date.getMonth(...)Call with the arguments your case needs.

Built into JavaScript. Call getMonth(...) on a Date instance — no import required.

Library declarations
JavaScript
date.getMonth()

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*The value returned by date.getMonth().

JavaScript Examples

Example 1 — Read the Local Month Index

Call getMonth() on fixed local dates (MDN-style July and December).

JavaScript
const july = new Date(1969, 6, 20);      // July 20, 1969
const december = new Date(1995, 11, 25);  // Dec 25, 1995

console.log(july.getMonth());      // 6
console.log(december.getMonth());  // 11
Try It Yourself

How It Works

  1. Zero-based constructor. Month 6 is July; month 11 is December.
  2. July. getMonth() returns 6 — same index you passed in.
  3. December. Returns 11, not 12.
  4. No mutation. The Date values are unchanged.

Example 2 — Map Index to a Month Name

Use the return value to index an array of names (MDN pattern).

JavaScript
const monthNames = [
  "January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"
];

const valentines = new Date(1995, 1, 14); // February 14
const month = valentines.getMonth();

console.log(month);              // 1
console.log(monthNames[month]);  // "February"
Try It Yourself

How It Works

  1. Build February 14. Constructor month 1 is February.
  2. Read the index. getMonth() returns 1.
  3. Lookup. monthNames[1] is "February".
  4. i18n tip. For other languages, prefer Intl.DateTimeFormat over a hard-coded English array (MDN).

Example 3 — getMonth() vs getUTCMonth()

Local and UTC month indexes can disagree near month boundaries.

JavaScript
const d = new Date("1995-12-25T23:15:30Z"); // Dec 25, 1995 UTC

console.log(d.getUTCMonth()); // 11
console.log(d.getMonth());    // local month (often 11, sometimes not)
Try It Yourself

How It Works

  1. UTC instant. The Z suffix is December 25 in UTC.
  2. UTC getter. getUTCMonth() reports 11 for that instant.
  3. Local getter. getMonth() applies your timezone — usually 11, but can differ near the month edge.
  4. Rule. Need local calendar month → getMonth(); need UTC → getUTCMonth().

Browser & Runtime Support

Date.prototype.getMonth() is part of the language from early ECMAScript and is Baseline Widely available (MDN).

✓ Baseline · Widely available

Date.prototype.getMonth()

Supported in every modern browser and Node.js. No polyfill needed for ordinary web apps.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Date.getMonth() Excellent

Bottom line: Safe everywhere. Focus on the zero-based index, timezone choice (local vs UTC), and invalid-Date checks.

Frequently Asked Questions

An integer from 0 to 11 for the month in local time. 0 is January, 1 is February, … 11 is December. Invalid Dates return NaN.
JavaScript uses a zero-based month index — the same as the Date constructor’s second argument. Add 1 when you need human month numbers 1–12.
getMonth() uses the local timezone. getUTCMonth() uses UTC. Near midnight on month boundaries they can differ by one month.
NaN. Validate with Number.isNaN(date.getTime()) before using the result.
Index an English names array with getMonth(), or prefer Intl.DateTimeFormat / toLocaleDateString({ month: "long" }) for locale-aware names (MDN).
Yes. new Date(2026, 2, 15) creates March 15, and getMonth() returns 2 — the same zero-based index you passed in.

Next: getSeconds()

Learn how to read the local seconds field (0–59) from a Date.

getSeconds() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful