JavaScript Date setUTCMonth() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
UTC month 0–11

What You’ll Learn

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

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.

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).

📝 Syntax

JavaScript
dateObj.setUTCMonth(monthIndex)
dateObj.setUTCMonth(monthIndex, dayOfMonth)

Parameters

  • monthIndex — Integer 0–11 (0 = January, 11 = December; overflow normalizes).
  • 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.

⚡ Quick Reference

GoalCode
Set UTC month to April (keep day)date.setUTCMonth(3)
Set UTC month and daydate.setUTCMonth(5, 15)
Add 3 UTC monthsdate.setUTCMonth(date.getUTCMonth() + 3)
First of UTC monthdate.setUTCMonth(m, 1)
Read UTC month after setdate.getUTCMonth()
Local month setterdate.setMonth(3)

📋 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

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"
Try It Yourself

How It Works

Month index 3 is April. With no day argument, the 15th UTC is preserved.

📈 Practical Patterns

End-of-month overflow, combined month/day, relative shifts, and year rollover.

Example 2 — End-of-Month Overflow (Jan 31 UTC → February)

February has fewer than 31 days, so the UTC date rolls into March.

JavaScript
const date = new Date(Date.UTC(2026, 0, 31)); // Jan 31, 2026 UTC
date.setUTCMonth(1); // February

console.log(date.getUTCMonth());     // 2 (March — overflow)
console.log(date.getUTCDate());      // 3
console.log(date.getUTCFullYear());  // 2026
Try It Yourself

How It Works

Feb 2026 has 28 days. Day 31 overflows by 3 days into March 3 UTC. Use setUTCMonth(1, 28) or the last day of month if you need to clamp instead.

Example 3 — Set UTC Month and Day Together (setUTCMonth(5, 15))

Jump directly to June 15 UTC regardless of the previous calendar date.

JavaScript
const date = new Date(Date.UTC(2026, 0, 1)); // Jan 1, 2026 UTC
date.setUTCMonth(5, 15); // June 15

console.log(date.getUTCMonth());  // 5
console.log(date.getUTCDate());   // 15
console.log(date.toISOString());  // "2026-06-15T00:00:00.000Z"
Try It Yourself

How It Works

The two-argument form sets both UTC month index and day-of-month in one call.

Example 4 — Add Three UTC Months (Clone First)

Schedule a renewal three months out while preserving the original Date.

JavaScript
const start = new Date(Date.UTC(2026, 8, 10)); // Sep 10, 2026 UTC
const renewal = new Date(start);
renewal.setUTCMonth(renewal.getUTCMonth() + 3);

console.log("Start month:", start.getUTCMonth());      // 8
console.log("Renewal month:", renewal.getUTCMonth());  // 11 (December)
Try It Yourself

How It Works

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
Try It Yourself

How It Works

Index 12 is one month past December (11), so the UTC year increments and the month becomes January (0).

🚀 Common Use Cases

  • UTC subscription renewalssetUTCMonth(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 snapssetUTCMonth(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.

📝 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.

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 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.setUTCMonth() Excellent

Bottom line: Safe everywhere. Remember zero-indexed months, the Jan 31 trap, and UTC vs local setters.

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.

💡 Best Practices

✅ Do

  • Think in 0–11 indices (April = 3)
  • Verify with toISOString() after changes
  • Pair with getUTCMonth() for relative month shifts
  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about Date.setUTCMonth()

Your foundation for UTC month writes in JavaScript.

5
Core concepts
🌐 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.

Continue to setUTCSeconds()

Learn how to set the UTC second field (0–59) on a Date object.

setUTCSeconds() 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.

6 people found this page helpful