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
Fundamentals
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.
Concept
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.
Foundation
📝 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.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Set UTC day to 15
date.setUTCDate(15)
Add 7 UTC days
date.setUTCDate(date.getUTCDate() + 7)
Read UTC day after set
date.getUTCDate()
Local day setter
date.setDate(n)
Verify in ISO
date.toISOString()
Clone before mutate
const copy = new Date(date)
Compare
📋 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
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 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"
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"
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Date.setUTCDate()
Your foundation for UTC day writes in JavaScript.
5
Core concepts
📝01
Syntax
setUTCDate(d)
API
🌐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.