getMonth() returns the month as a zero-based index from 0 to 11 in local time (January = 0). This guide covers syntax, five examples, month-name mapping, UTC comparisons, and the off-by-one pitfall every beginner hits.
01
Syntax
date.getMonth()
02
Range
0 – 11
03
Jan = 0
Zero-based
04
+1 rule
Human 1–12
05
Names
Array / locale
06
Validate
Invalid → NaN
Fundamentals
Introduction
Filters, billing cycles, and “posted in March” labels need the month from a Date. The getMonth() method returns that value as an integer—but unlike calendar labels, JavaScript counts months from zero.
Combine it with getFullYear() and getDate() to build custom date strings, or use toLocaleDateString() when locale formatting is enough.
Concept
Understanding the getMonth() Method
Date.prototype.getMonth() is a zero-argument instance method. It never mutates the original Date—it only reads the month index according to local time rules.
The zero-based index matches the second argument of new Date(year, monthIndex, day). If you create new Date(2026, 2, 15), getMonth() returns 2 (March).
💡
Beginner Tip
Memory hook: getMonth() + 1 gives calendar month numbers (1–12). February is index 1, not 2.
Foundation
📝 Syntax
JavaScript
dateObj.getMonth()
Parameters
None.
Return value
Integer 0–11 for a valid date in local time.
NaN if dateObj is an invalid Date.
Month index table
0 — January
1 — February
2 — March
3 — April
4 — May
5 — June
6 — July
7 — August
8 — September
9 — October
10 — November
11 — December
Cheat Sheet
⚡ Quick Reference
Goal
Code
Current month index
new Date().getMonth()
Human month 1–12
date.getMonth() + 1
Month from fixed date
new Date(2026, 1, 15).getMonth() → 1 (Feb)
UTC month index
date.getUTCMonth()
Month name (locale)
date.toLocaleString("en-US", { month: "long" })
Valid date check
!Number.isNaN(date.getTime())
Compare
📋 getMonth() vs Similar Methods
These getters answer different calendar questions. Match the method to what your UI or filter needs.
getMonth()
0–11
Local month index
getUTCMonth()
UTC index
Timezone-safe read
getDate()
1–31
Day of month
getFullYear()
2026
Four-digit year
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Fixed dates use new Date(year, monthIndex, day) so indexes stay predictable.
📚 Getting Started
Read the zero-based month index from a known date.
Month alone is not enough across years—June 2025 and June 2026 both return index 5 but are different calendar months. Include getFullYear() when it matters.
Applications
🚀 Common Use Cases
Month filters — show records from “this month.”
Billing — detect month-end and renewal dates.
Seasonal UI — swap themes by month index.
Form defaults — pre-select month in date pickers.
Analytics — group events by calendar month.
Date labels — build “Feb 15, 2026” strings.
🧠 How getMonth() Resolves the Month
1
Internal instant
The Date stores milliseconds since Unix epoch (UTC).
Storage
2
Local conversion
Engine applies the runtime timezone offset.
TZ
3
Extract month
Zero-based index 0–11 is returned.
getMonth
4
📅
Map or compare
Add 1, map to names, filter, or pass to setMonth.
Important
📝 Notes
getMonth() is zero-based (January = 0).
Use getUTCMonth() when you standardize on UTC.
Invalid dates propagate NaN—validate first.
Compare with getFullYear() when month spans years matter.
setMonth(getMonth() + 1) adds one month with automatic year rollover.
For display, prefer locale formatters over hard-coded English arrays.
Compatibility
Browser & Runtime Support
Date.prototype.getMonth() has been available since the first JavaScript Date implementation (ES1). It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.getMonth()
Supported in Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions. No polyfill required.
99%Universal API
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Date.getMonth()Excellent
Bottom line: Safe everywhere. Remember the zero-based index—February is 1, not 2.
Wrap Up
Conclusion
getMonth() reads the local month as a zero-based index from 0 to 11. Add one for human calendar numbers, map to names for display, and always pair with getFullYear() when comparing months across years.
Next, learn getSeconds() for the second component, or setMonth() to write the month index directly.
Use locale formatters for month names in production
❌ Don’t
Assume February is index 2
Confuse getMonth() with getDate()
Ignore NaN from bad parses
Compare months without checking the year
Hard-code English names in multilingual apps
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Date.getMonth()
Your foundation for month reads in JavaScript.
5
Core concepts
📝01
Syntax
date.getMonth()
API
🔢02
0–11
Jan = 0.
Range
🌐03
Local
Not UTC.
Timezone
🔄04
+1
Human 1–12.
Convert
⚠05
Feb = 1
Not 2.
Pitfall
❓ Frequently Asked Questions
An integer from 0 to 11 representing the month in the Date object's local timezone. 0 is January, 1 is February, … 11 is December.
JavaScript follows the same zero-based month index as the Date constructor's second argument. Add 1 when you need human-readable month numbers 1–12.
getMonth() uses local timezone rules. getUTCMonth() reads the UTC month index. Near midnight on month boundaries they can differ.
NaN. Validate with !Number.isNaN(date.getTime()) before using the result.
Use date.toLocaleString('en-US', { month: 'long' }) for locale-aware names, or map getMonth() to an array of English month strings.
Yes. new Date(2026, 2, 15) creates March 15 and getMonth() returns 2—the same zero-based index you passed in.
Did you know?
The Date constructor and getMonth() share the same zero-based month index. If you pass 2 to new Date(2026, 2, 15), getMonth() returns 2 (March)—no conversion needed when building and reading the same date.