JavaScript Date setUTCMonth() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.prototype.setUTCMonth() changes the month (and optionally the day of the month) of a Date in UTC. Months are zero-indexed (0 = January … 11 = December). It mutates the date in place and returns the new epoch timestamp.

Remember
date.setUTCMonth(monthValue)
date.setUTCMonth(monthValue, dateValue)

monthValue → 0–11 (0 = Jan, 11 = Dec)
dateValue  → day of month 1–31 (optional)
overflow   → rolls year / day as needed
returns    → epoch milliseconds (or NaN)

setUTCMonth() → UTC calendar
setMonth()    → local calendar

Syntax

Call date.setUTCMonth. Start with this line.

JavaScript
date.setUTCMonth(m[, day])
CallWhat it does
date.setUTCMonth(m[, day])Primary signature.
date.setUTCMonth(...)Call with the arguments your case needs.

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

Library declarations
JavaScript
date.setUTCMonth(m[, day])

Parameters

ParameterDescription
monthValueRequired. UTC month index (0–11; overflow allowed)
dateValueOptional. UTC day of month (1–31)

Return Value

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

JavaScript Examples

Example 1 — Set the UTC Month

Move from January to March while keeping the day.

JavaScript
const date = new Date(Date.UTC(2026, 0, 15)); // Jan 15
date.setUTCMonth(2); // March

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

How It Works

  1. Build a UTC date. Date.UTC(2026, 0, 15) is January 15, 2026 UTC (month index 0).
  2. Set March. setUTCMonth(2) uses index 2, not 3.
  3. Keep the day. Day 15 stays because March has at least 15 days.
  4. Confirm ISO. Result is 2026-03-15T00:00:00.000Z.

Example 2 — Set Month and Day Together

Pass a second argument to land on a specific UTC calendar day.

JavaScript
const date = new Date(Date.UTC(2026, 0, 15));
date.setUTCMonth(2, 1); // March 1

console.log(date.getUTCMonth()); // 2
console.log(date.getUTCDate());  // 1
console.log(date.toISOString()); // "2026-03-01T00:00:00.000Z"
Try It Yourself

How It Works

  1. Start mid-month. The date begins on January 15.
  2. Pass two args. Month 2 (March) and day 1.
  3. Replace the day. You are not stuck with day 15 anymore.
  4. Why it helps. Safer than omitting the day when the old day might not exist in the new month.

Example 3 — Day Overflow (Jan 31 → February)

Shorter months do not clamp — they spill into the next month.

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

console.log(date.getUTCMonth()); // 2  (March!)
console.log(date.getUTCDate());  // 3
console.log(date.toISOString()); // "2026-03-03T00:00:00.000Z"
Try It Yourself

How It Works

  1. Start Jan 31. Day is 31.
  2. Target February. setUTCMonth(1) keeps day 31.
  3. Normalize. Feb 2026 has 28 days, so day 31 spills to March 3.
  4. Avoid the trap. Prefer setUTCMonth(1, 1) or clamp the day before changing months.

Browser & Runtime Support

Date.prototype.setUTCMonth() has been in JavaScript since ES1. It is Baseline and works in every modern browser and Node.js — no polyfill needed.

✓ Baseline · ES1

Date.prototype.setUTCMonth()

Supported everywhere Date exists: Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions.

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 to use in any environment. Remember zero-based months, day overflow, and UTC vs local. See also the MDN setUTCMonth() reference.

Frequently Asked Questions

It sets the month index (0–11) of a Date according to universal time (UTC). An optional day argument can also set the UTC day of the month. The Date mutates in place and returns the new timestamp in milliseconds.
JavaScript Date months are zero-indexed, same as getUTCMonth(): 0 = January through 11 = December. March is 2, not 3.
The current UTC day-of-month is kept (from getUTCDate), unless overflow normalization changes it—for example Jan 31 into a shorter month.
February has fewer than 31 days. JavaScript normalizes overflow—Jan 31, 2026 UTC becomes March 3, 2026 UTC (not Feb 28).
No. It returns a number (epoch milliseconds), or NaN if the date becomes invalid. Call each setter on the same Date variable—do not chain on the return value.
setMonth() changes the local calendar month. setUTCMonth() changes the UTC calendar month. Use the setter that matches your timezone rules.

Next: setUTCSeconds()

Learn how to set the UTC seconds (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.

11 people found this page helpful