JavaScript Date setUTCDate() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
UTC day (1–31)

What You’ll Learn

setUTCDate() writes the day-of-month (1–31) on a Date in UTC. This guide covers syntax, UTC day arithmetic, overflow, and comparisons with local setDate().

01

Syntax

setUTCDate(d)

02

1–31

UTC day

03

vs setDate

UTC vs local

04

+ days

getUTCDate + n

05

Overflow

Next month

06

Returns

Epoch ms

Introduction

ISO timestamps, server logs, and global billing often follow UTC calendar rules. After reading the UTC day with getUTCDate(), setUTCDate() writes it back without using local timezone offsets.

Like setDate(), it mutates the Date and returns epoch milliseconds. Use UTC getters and setters together—do not mix local setDate with UTC getUTCDate in one calculation.

Understanding the setUTCDate() Method

Date.prototype.setUTCDate(dayOfMonth) accepts an integer for the UTC calendar day. Values outside 1–31 normalize into adjacent UTC months—the same overflow behavior as local setDate().

UTC time-of-day fields (hours, minutes, seconds) stay the same unless day overflow rolls the UTC calendar. Verify results with toISOString() or getUTCDate().

💡
Beginner Tip

Add UTC days: date.setUTCDate(date.getUTCDate() + 7). Build UTC dates with Date.UTC(year, monthIndex, day) for predictable examples.

📝 Syntax

JavaScript
dateObj.setUTCDate(dayOfMonth)

Parameters

  • dayOfMonth — Integer 1–31 in UTC (overflow normalizes; day 0 rolls to the last day of the previous UTC month).

Return value

  • Updated epoch milliseconds after the change.
  • NaN if the Date was invalid before the call.

⚡ Quick Reference

GoalCode
Set UTC day to 15date.setUTCDate(15)
Add 7 UTC daysdate.setUTCDate(date.getUTCDate() + 7)
Read UTC day after setdate.getUTCDate()
Local day setterdate.setDate(n)
Verify in ISOdate.toISOString()
Clone before mutateconst copy = new Date(date)

📋 setUTCDate() vs Similar Methods

Pick the setter that matches your timezone rules.

setUTCDate()
UTC 1–31

UTC day

getUTCDate()
read

Getter pair

setDate()
local 1–31

Local setter

setTime()
full ms

Epoch 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 day-of-month on an existing Date.

Example 1 — Set the UTC Day to the 15th

Start on 10 February 2026 UTC and move to the 15th.

JavaScript
const date = new Date(Date.UTC(2026, 1, 10, 12, 0, 0));
date.setUTCDate(15);

console.log(date.getUTCDate());   // 15
console.log(date.toISOString());  // "2026-02-15T12:00:00.000Z"
Try It Yourself

How It Works

Only the UTC calendar day changes. The Z suffix in ISO strings confirms UTC time-of-day is unchanged.

📈 Practical Patterns

UTC day arithmetic, return values, overflow, and month-end helpers.

Example 2 — Add Seven UTC Days

The UTC equivalent of setDate(getDate() + 7).

JavaScript
const date = new Date(Date.UTC(2026, 0, 28, 0, 0, 0));
date.setUTCDate(date.getUTCDate() + 7);

console.log(date.getUTCMonth());  // 1 (February)
console.log(date.getUTCDate());   // 4
Try It Yourself

How It Works

Jan 28 UTC + 7 days overflows into February 4 UTC. Use UTC getters throughout the expression.

Example 3 — Use the Return Value (Epoch Milliseconds)

setUTCDate returns the updated timestamp—same as getTime() after the change.

JavaScript
const date = new Date(Date.UTC(2026, 2, 15));
const ms = date.setUTCDate(20);

console.log("Type:", typeof ms);                    // "number"
console.log("Matches getTime():", ms === date.getTime()); // true
Try It Yourself

How It Works

Do not chain field setters on the numeric return value—mutate the same date variable instead.

Example 4 — UTC Month Overflow (setUTCDate(32))

Day 32 on a January UTC date rolls into February.

JavaScript
const date = new Date(Date.UTC(2026, 0, 15, 8, 0, 0));
date.setUTCDate(32);

console.log(date.getUTCMonth());  // 1 (February)
console.log(date.getUTCDate());   // 1
Try It Yourself

How It Works

Overflow normalizes instead of clamping. January 15 + day 32 becomes February 1 in the UTC calendar.

Example 5 — Jump to the Last Day of the UTC Month

Use setUTCDate(0) after moving to the next UTC month—day 0 means the last day of the previous month.

JavaScript
const date = new Date(Date.UTC(2026, 1, 10)); // Feb 10 UTC
date.setUTCMonth(date.getUTCMonth() + 1, 0);   // March 0 = last day of Feb

console.log(date.getUTCDate());   // 28
console.log(date.toISOString());  // "2026-02-28T00:00:00.000Z"
Try It Yourself

How It Works

setUTCMonth(m + 1, 0) sets day 0 of the next month, which is the last day of month m. February 2026 has 28 days.

🚀 Common Use Cases

  • ISO date math — shift UTC days on parsed timestamps.
  • Global billing — anchor renewals to UTC calendar days.
  • Log aggregation — bucket by UTC day with getUTCDate / setUTCDate.
  • Server schedules — cron rules that follow UTC, not local wall clock.
  • Month-end UTC — last-day helpers via day 0 overflow.
  • Clone + mutate — copy before changing UTC days for comparisons.

🧠 How setUTCDate() Updates the UTC Calendar

1

Read UTC fields

Engine loads UTC year, month, and day-of-month.

UTC
2

Apply new day

The day argument replaces the UTC day-of-month.

setUTCDate
3

Normalize overflow

Invalid days roll into adjacent UTC months or years.

Normalize
4

Mutate & return ms

Date updates in place; epoch milliseconds are returned.

📝 Notes

  • setUTCDate() changes the UTC calendar day—not the local one from getDate().
  • Use UTC getters with UTC setters; mixing local and UTC in one label causes off-by-one bugs.
  • Day 0 is valid—it means the last day of the previous UTC month.
  • Mutates the original Date—clone with new Date(date) when needed.
  • Returns epoch ms, not the Date—no fluent chaining on the return value.
  • Prefer toISOString() to verify UTC results in examples and tests.

Browser & Runtime Support

Date.prototype.setUTCDate() has been available since ES1. It works in every browser and Node.js.

Baseline · ES1

Date.prototype.setUTCDate()

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

Bottom line: Safe everywhere. Pair with getUTCDate() and keep UTC math in UTC.

Conclusion

setUTCDate() writes the UTC day-of-month (1–31) on a JavaScript Date. Use it for ISO-aligned day math; use setDate() for local user calendars.

Next, learn setUTCFullYear() to change the UTC year, or review getUTCDate() for reading the UTC day.

💡 Best Practices

✅ Do

  • Use setUTCDate(getUTCDate() + n) for UTC day shifts
  • Build test dates with Date.UTC()
  • Verify with toISOString() and getUTCDate()
  • Clone before mutating shared Date instances
  • Use local setDate for user-facing UI calendars

❌ Don’t

  • Mix setUTCDate with getDate() in one step
  • Assume days clamp at 31 (overflow rolls months)
  • Chain setters on the numeric return value
  • Parse ambiguous date strings without UTC awareness
  • Manually clamp 1–31 when overflow normalization is fine

Key Takeaways

Knowledge Unlocked

Five things to remember about Date.setUTCDate()

Your foundation for UTC day writes in JavaScript.

5
Core concepts
🌐 02

UTC

Not local.

Timezone
03

+ days

getUTCDate + n.

Pattern
📈 04

Overflow

Rolls months.

Normalize
🔄 05

Day 0

Prev month end.

Trick

❓ Frequently Asked Questions

It sets the day-of-month (1–31) of a Date object in UTC. The Date mutates in place and returns updated epoch milliseconds.
setDate() changes the local calendar day. setUTCDate() changes the UTC calendar day. They can produce different results when local timezone offset crosses midnight.
getUTCDate() reads the current UTC day-of-month. setUTCDate(day) writes it. They are the read/write pair for UTC calendar days.
Use date.setUTCDate(date.getUTCDate() + 7). Overflow into the next UTC month is normalized automatically.
JavaScript normalizes overflow into the next UTC month. setUTCDate(32) on January 15 UTC rolls to February 1 UTC (or later days depending on the starting date).
No. It returns a number (epoch milliseconds). Call each setter on the same Date variable—do not chain on the return value.
Did you know?

setUTCDate(0) moves to the last day of the previous UTC month—that is why setUTCMonth(month + 1, 0) finds the last day of the current UTC month. The old tutorial’s “setUTCDate(0) then setUTCDate(1)” pattern did not compute month-end correctly.

Continue to setUTCFullYear()

Learn how to set the UTC four-digit year on a Date object.

setUTCFullYear() 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