setUTCSeconds() writes the second (0–59) on a Date in UTC, with optional milliseconds. This guide covers syntax, minute snaps, combined second/ms overload, overflow, and comparisons with local setSeconds().
01
Syntax
setUTCSeconds(s)
02
0–59 UTC
Second hand
03
+ ms
2-arg form
04
:00 snap
Minute start
05
Overflow
Rolls minutes
06
Returns
Epoch ms
Fundamentals
Introduction
ISO timestamps and server logs often need precise UTC second fields. After reading the UTC second with getUTCSeconds(), setUTCSeconds() writes it back without local timezone offsets.
Like setSeconds(), it mutates the Date and returns epoch milliseconds. Use UTC getters and setters together—do not mix local setSeconds with UTC getUTCSeconds in one step.
Concept
Understanding the setUTCSeconds() Method
Date.prototype.setUTCSeconds(second [, millisecond]) accepts a UTC second and an optional UTC millisecond. When you pass only the second, UTC milliseconds stay the same unless overflow normalization rolls the clock.
90 seconds = 1 minute + 30 seconds. The engine normalizes instead of clamping to 59.
Applications
🚀 Common Use Cases
UTC log alignment — setUTCSeconds(0, 0) for minute buckets.
ISO timestamps — apply second/ms from parsed UTC strings.
Test fixtures — pin exact UTC second/ms with Date.UTC().
Cron alignment — snap events to :00 at UTC minute boundaries.
API sync — align server timestamps to UTC second precision.
Clone + mutate — keep originals when tweaking sub-minute UTC fields.
🧠 How setUTCSeconds() Updates the UTC Clock
1
Read UTC time
Engine loads UTC hour, minute, second, and ms fields.
UTC
2
Apply new second
Second and optional ms replace old UTC values.
setUTCSeconds
3
Normalize overflow
Out-of-range values roll into adjacent UTC minutes or hours.
Normalize
4
🌐
Mutate & return ms
Date updates in place; epoch milliseconds are returned.
Important
📝 Notes
setUTCSeconds() adjusts the second hand in UTC (0–59 typical range).
Mutates the original Date—clone with new Date(date) when needed.
Returns epoch ms, not the Date—no fluent chaining on the return value.
Overflow normalizes (second 90 → next UTC minute + 30 seconds).
Omitting the ms argument does not reset milliseconds to zero.
Use setSeconds for local clocks; setUTCSeconds for ISO/server rules.
Compatibility
Browser & Runtime Support
Date.prototype.setUTCSeconds() has been available since ES1. It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.setUTCSeconds()
Supported in Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions. No polyfill required.
99%Universal API
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Date.setUTCSeconds()Excellent
Bottom line: Safe everywhere. Remember UTC vs local setters, mutation, and the two-argument snap pattern.
Wrap Up
Conclusion
setUTCSeconds() writes the UTC second (and optionally milliseconds) on a JavaScript Date. Use it for ISO-aligned sub-minute precision; use setSeconds() for local wall clocks.
That completes the UTC setter family. Next, learn toDateString() for readable local date labels, or review getUTCSeconds() for reading the UTC second.
Use setUTCSeconds(0, 0) to snap to UTC minute boundaries
Verify with toISOString() after changes
Pair with getUTCSeconds() for read/write workflows
Use the two-arg overload for exact :SS.ms UTC marks
Clone before mutating shared Date instances
❌ Don’t
Mix setUTCSeconds with getSeconds() in one calculation
Chain setters on the numeric return value
Assume values clamp at 59 (overflow rolls minutes)
Use setUTCSeconds(n) as a countdown timer (use epoch math instead)
Use local setters when ISO UTC rules apply
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Date.setUTCSeconds()
Your foundation for UTC second writes in JavaScript.
5
Core concepts
📝01
Syntax
setUTCSeconds(s)
API
🌐02
0–59 UTC
Second hand.
Range
📈03
2 args
s + ms.
Overload
📈04
:00 snap
Minute start.
Pattern
🔄05
Mutates
In place.
Behavior
❓ Frequently Asked Questions
It sets the seconds (0–59) of a Date object in UTC. An optional milliseconds argument can also set sub-second precision. The Date mutates in place and returns updated epoch milliseconds.
getUTCSeconds() reads the current UTC second. setUTCSeconds(s) writes a new UTC second. They are the read/write pair for the second hand of the UTC clock.
Yes. setUTCSeconds(second, millisecond) updates both UTC fields at once—useful for snapping to :00.000 at the start of a UTC minute.
JavaScript normalizes overflow into the next UTC minute. setUTCSeconds(90) on 12:30:45 UTC becomes 12:31:30 UTC (90 seconds = 1 minute + 30 seconds).
No. It returns a number (epoch milliseconds). Call each setter on the same Date variable—do not chain on the return value.
setUTCSeconds() changes the UTC clock second. setSeconds() changes the local clock second. Use the one that matches your timezone rules.
Did you know?
setUTCSeconds(0, 0) snaps ISO strings to ...:MM:00.000Z—the same instant may show non-zero local seconds in getSeconds() when your timezone offset is not a whole number of hours.