JavaScript Date setUTCDate() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.prototype.setUTCDate() changes the day of the month for this date according to universal time (UTC) (MDN). It mutates the Date in place and returns the new timestamp.

Remember
date.setUTCDate(dateValue)

dateValue: typically 1 … 31 (UTC day)
→ returns new timestamp (ms)
→ mutates date

setUTCDate(19)   // set UTC day to 19
setUTCDate(32)   // overflow → next month
setUTCDate(0)    // last day of previous month

Syntax

Call date.setUTCDate. Start with this line.

JavaScript
date.setUTCDate(day)
CallWhat it does
date.setUTCDate(day)Primary signature.
date.setUTCDate(...)Call with the arguments your case needs.

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

Library declarations
JavaScript
date.setUTCDate(day)

Parameters

ParameterDescription
dateValueRequired. UTC day of month (1–31 typical; overflow OK)

Return Value

Return ValueDescription
*New epoch ms (number), not the Date

JavaScript Examples

Example 1 — Set the UTC Day of Month

MDN: read the UTC day, then change it with setUTCDate().

JavaScript
const event = new Date("August 19, 1975 23:15:30 GMT-3:00");

console.log(event.getUTCDate()); // 20

event.setUTCDate(19);

console.log(event.getUTCDate()); // 19
Try It Yourself

How It Works

  1. Parse with offset. GMT-3:00 shifts the instant so UTC day is 20.
  2. Read. getUTCDate() reports 20.
  3. Write. setUTCDate(19) sets the UTC calendar day to 19.
  4. Object mutated. The same event now reads day 19.

Example 2 — Day Overflow Rolls to the Next Month

Values past the end of the month normalize forward (MDN).

JavaScript
const d = new Date(Date.UTC(2026, 0, 31)); // Jan 31, 2026 UTC

d.setUTCDate(32);

console.log(d.getUTCMonth()); // 1  (February)
console.log(d.getUTCDate());  // 1
console.log(d.toISOString()); // "2026-02-01T00:00:00.000Z"
Try It Yourself

How It Works

  1. Start Jan 31. January has 31 days.
  2. Ask for day 32. That is past the end of January.
  3. Engine normalizes. Day 32 → February 1.
  4. Read back. Month index 1, day 1.

Example 3 — setUTCDate(0) → Last Day of Previous Month

Day 0 counts back into the previous UTC month (MDN).

JavaScript
const d = new Date(Date.UTC(2026, 0, 15)); // Jan 15, 2026 UTC

d.setUTCDate(0);

console.log(d.toISOString()); // "2025-12-31T00:00:00.000Z"
console.log(d.getUTCDate());  // 31
Try It Yourself

How It Works

  1. Start mid-January. Any day in January works as a base.
  2. Pass 0. That means “day before the 1st” of the current month.
  3. Land on Dec 31. Last day of the previous UTC month.
  4. Use case. End-of-previous-month without hard-coding month lengths.

Browser & Runtime Support

Date.prototype.setUTCDate() is part of the language from early ECMAScript and is Baseline Widely available (MDN).

✓ Baseline · Widely available

Date.prototype.setUTCDate()

Supported in every modern browser and Node.js. No polyfill needed for ordinary web apps.

99% Modern browser support
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. Focus on mutation, month overflow, and UTC vs local choice.

Frequently Asked Questions

It sets the day of the month (typically 1–31) of a Date according to UTC. The Date mutates in place and the method returns the new timestamp in milliseconds.
setDate() changes the local calendar day. setUTCDate() changes the UTC calendar day. They can differ when the timezone offset crosses midnight.
getUTCDate() reads the UTC day-of-month. setUTCDate(day) writes it. They are the read/write pair for UTC calendar days.
JavaScript normalizes overflow into the next month. January 31 + setUTCDate(32) becomes February 1 (MDN-style overflow).
It sets the date to the last day of the previous UTC month. Useful for “end of last month” without hard-coding month lengths.
No. It returns a number (epoch milliseconds). Call setters on the Date variable — do not chain on the return value.

Next: setUTCFullYear()

Learn how to set the UTC year, and optionally month and day, on a Date.

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.

11 people found this page helpful