setUTCMonth() writes the month index (0–11) on a Date in UTC, with an optional day-of-month. This guide covers zero-indexed months, end-of-month overflow, relative month shifts, and comparisons with local setMonth().
01
Syntax
setUTCMonth(m)
02
0–11
Jan = 0
03
+ day
Optional
04
+ months
getUTCMonth
05
Overflow
Jan 31 trap
06
Returns
Epoch ms
Fundamentals
Introduction
Billing cycles, ISO reports, and server-side date math often use UTC calendar fields. After reading the UTC month with getUTCMonth(), setUTCMonth() writes it back without local timezone offsets.
Like setMonth(), months are zero-indexed (0 = January, 11 = December) and the method mutates the Date in place, returning epoch milliseconds.
Concept
Understanding the setUTCMonth() Method
Date.prototype.setUTCMonth(monthIndex [, dayOfMonth]) accepts a UTC month index and an optional UTC day. When you pass only the month, the UTC day-of-month is not reset to 1—it stays the same unless overflow normalization rolls the calendar.
Verify results with toISOString() or UTC getters. For changing the UTC year, pair with setUTCFullYear().
💡
Beginner Tip
May is index 4, not 5. To jump to June 15 UTC: date.setUTCMonth(5, 15). To add three months: date.setUTCMonth(date.getUTCMonth() + 3).
dayOfMonth (optional) — UTC day of month (1–31 typical range; overflow normalizes).
Return value
Updated epoch milliseconds after the change.
NaN if the Date was invalid before the call.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Set UTC month to April (keep day)
date.setUTCMonth(3)
Set UTC month and day
date.setUTCMonth(5, 15)
Add 3 UTC months
date.setUTCMonth(date.getUTCMonth() + 3)
First of UTC month
date.setUTCMonth(m, 1)
Read UTC month after set
date.getUTCMonth()
Local month setter
date.setMonth(3)
Compare
📋 setUTCMonth() vs Similar Methods
Pick the setter that matches the calendar field and timezone you need.
setUTCMonth()
UTC 0–11
UTC month
getUTCMonth()
read
Getter pair
setMonth()
local 0–11
Local setter
setUTCFullYear()
UTC year
Year setter
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Examples use Date.UTC() for predictable UTC calendar values.
📚 Getting Started
Change the UTC month index while keeping the day when possible.
Example 1 — Set UTC Month to April (3) and Keep the Day
Start on February 15 UTC and move to April 15 UTC.
JavaScript
const date = new Date(Date.UTC(2026, 1, 15)); // Feb 15, 2026 UTC
date.setUTCMonth(3); // April
console.log(date.getUTCMonth()); // 3
console.log(date.getUTCDate()); // 15
console.log(date.toISOString()); // "2026-04-15T00:00:00.000Z"
Clone before mutating when other code still needs the original instant. Use getUTCMonth(), not getMonth().
Example 5 — UTC Month Index Overflow (setUTCMonth(12))
Month index 12 normalizes into January of the next UTC year.
JavaScript
const date = new Date(Date.UTC(2026, 10, 20)); // Nov 20, 2026 UTC
date.setUTCMonth(12);
console.log(date.getUTCMonth()); // 0 (January)
console.log(date.getUTCFullYear()); // 2027
Index 12 is one month past December (11), so the UTC year increments and the month becomes January (0).
Applications
🚀 Common Use Cases
UTC subscription renewals — setUTCMonth(getUTCMonth() + 1) monthly billing.
Quarterly UTC reports — add three months for ISO-aligned periods.
Season pickers — map UI month names to 0–11 indices in UTC.
First-of-month snaps — setUTCMonth(m, 1) for UTC billing anchors.
End-of-month caution — validate Jan 31 UTC → Feb transitions.
Clone + mutate — keep originals when computing future UTC dates.
🧠 How setUTCMonth() Updates the UTC Calendar
1
Read UTC date
Engine loads UTC year, month index, and day-of-month.
UTC
2
Apply new month
Month index and optional day replace old UTC values.
setUTCMonth
3
Normalize overflow
Invalid day/month combos roll into adjacent UTC months or years.
Normalize
4
🌐
Mutate & return ms
Date updates in place; epoch milliseconds are returned.
Important
📝 Notes
Months are zero-indexed: 0 = January, 11 = December.
Omitting the day argument does not reset the day to 1.
Mutates the original Date—clone with new Date(date) when needed.
Returns epoch ms, not the Date—no fluent chaining on the return value.
Jan 31 → February can overflow into March (end-of-month trap).
Use setMonth for local calendars; setUTCMonth for ISO/server rules.
Compatibility
Browser & Runtime Support
Date.prototype.setUTCMonth() has been available since ES1. It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.setUTCMonth()
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.setUTCMonth()Excellent
Bottom line: Safe everywhere. Remember zero-indexed months, the Jan 31 trap, and UTC vs local setters.
Wrap Up
Conclusion
setUTCMonth() writes the UTC month index (and optionally the UTC day) on a JavaScript Date. Use it for ISO-aligned calendar math; use setMonth() for local wall calendars.
Next, learn setUTCSeconds() to change the UTC second field, or review getUTCMonth() for reading the UTC month index.
Use setUTCMonth(m, 1) for first-of-month UTC anchors
Clone before mutating shared Date instances
❌ Don’t
Assume January is index 1 (it is 0)
Expect the day to reset to 1 when you omit the day argument
Mix setUTCMonth with getMonth() in one calculation
Chain setters on the numeric return value
Ignore Jan 31 → February overflow in billing logic
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Date.setUTCMonth()
Your foundation for UTC month writes in JavaScript.
5
Core concepts
📝01
Syntax
setUTCMonth(m)
API
🌐02
0–11
Jan = 0.
Index
📈03
+ day
2-arg form.
Overload
⚠04
Jan 31
Overflow.
Trap
🔄05
Mutates
In place.
Behavior
❓ Frequently Asked Questions
It sets the month index (0–11) of a Date object in UTC. An optional day argument can also set the UTC day-of-month. The Date mutates in place and returns updated epoch milliseconds.
JavaScript Date months are zero-indexed like getUTCMonth(): 0 = January through 11 = December. April is index 3, not 4.
No. If you pass only the month index, the current UTC day-of-month stays the same unless overflow normalization changes it (e.g. Jan 31 UTC → February rolls into March).
February has fewer days than 31. JavaScript normalizes overflow—Jan 31, 2026 UTC becomes March 3, 2026 UTC (Feb 28 + 3 days).
No. It returns a number (epoch milliseconds). Call each setter on the same Date variable—do not chain on the return value.
setUTCMonth() changes the UTC calendar month. setMonth() changes the local calendar month. Use the one that matches your timezone rules.
Did you know?
setUTCMonth(4) sets May in UTC—not April. Month indices start at 0, matching getUTCMonth() output.