setUTCHours() writes the hour (0–23) on a Date in UTC, with optional minutes, seconds, and milliseconds. This guide covers syntax, ISO scheduling, overflow, and comparisons with local setHours().
01
Syntax
setUTCHours(h)
02
24h UTC
0 – 23
03
Overload
h, m, s, ms
04
+ hours
getUTCHours
05
Overflow
Rolls days
06
Returns
Epoch ms
Fundamentals
Introduction
Global events, cron jobs, and ISO timestamps often schedule by UTC clock time. After reading the UTC hour with getUTCHours(), setUTCHours() writes it back without local timezone offsets.
Like setHours(), it mutates the Date and returns epoch milliseconds. Use UTC getters and setters together—do not mix local setHours with UTC getUTCHours in one step.
Concept
Understanding the setUTCHours() Method
Date.prototype.setUTCHours(hour [, minute [, second [, millisecond]]]) accepts a 24-hour UTC hour and up to three optional sub-hour fields. When you pass only the hour, UTC minutes and seconds stay the same unless overflow normalization rolls the UTC calendar day.
Verify results with toISOString() or UTC getters. Hour 15 is 3:00 PM UTC in 24-hour time.
💡
Beginner Tip
To schedule at exactly 15:00:00.000 UTC: date.setUTCHours(15, 0, 0, 0). To add two UTC hours: date.setUTCHours(date.getUTCHours() + 2).
Overflow normalizes instead of clamping to 0–23. That helps when adding hours but can surprise if you expected rejection.
Applications
🚀 Common Use Cases
Global events — snap to setUTCHours(15, 0, 0, 0) for 3 PM UTC.
Server cron — schedule jobs on UTC wall clock, not local server TZ.
ISO APIs — align parsed timestamps to UTC hour boundaries.
Relative UTC shifts — postpone with getUTCHours() + N.
Log bucketing — group entries by UTC hour for global dashboards.
Clone + mutate — copy a Date before changing UTC hours.
🧠 How setUTCHours() Updates the UTC Clock
1
Read UTC time
Engine loads current UTC date and time fields.
UTC
2
Apply new hour
Hour and optional minute/second/ms replace old UTC values.
setUTCHours
3
Normalize overflow
Out-of-range values roll into adjacent UTC hours or days.
Normalize
4
🌐
Mutate & return ms
Date updates in place; epoch milliseconds are returned.
Important
📝 Notes
setUTCHours() uses 24-hour UTC time (0 = midnight UTC, 12 = noon UTC).
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 (hour 25 → next UTC day hour 1).
For real timezone conversion, use Intl or libraries—not naive offset math on getters.
Use setHours for local user-facing clocks; setUTCHours for ISO/server rules.
Compatibility
Browser & Runtime Support
Date.prototype.setUTCHours() has been available since ES1. It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.setUTCHours()
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.setUTCHours()Excellent
Bottom line: Safe everywhere. Remember 24-hour UTC time, mutation, and the four-argument snap pattern.
Wrap Up
Conclusion
setUTCHours() writes the UTC hour (and optionally minutes, seconds, and milliseconds) on a JavaScript Date. Use it for ISO-aligned scheduling; use setHours() for local wall clocks.
Use setUTCHours(15, 0, 0, 0) for exact UTC wall-clock times
Think in 24-hour UTC values (15 = 3 PM UTC)
Verify with toISOString() after changes
Pair with getUTCHours() for relative shifts
Clone before mutating shared Date instances
❌ Don’t
Mix setUTCHours with getHours() in one calculation
Chain setters on the numeric return value
Assume values clamp at 23 (overflow rolls days)
Use local setters for UTC cron rules
Forget midnight UTC is hour 0, not 24
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Date.setUTCHours()
Your foundation for UTC hour writes in JavaScript.
5
Core concepts
📝01
Syntax
setUTCHours(h)
API
🌐02
0–23 UTC
24-hour.
Range
📈03
4 args
h, m, s, ms.
Overload
➕04
+ hours
getUTCHours.
Pattern
🔄05
Mutates
In place.
Behavior
❓ Frequently Asked Questions
It sets the hour (0–23) of a Date object in UTC. Optional arguments can also set UTC minutes, seconds, and milliseconds. The Date mutates in place and returns updated epoch milliseconds.
setHours() changes the local clock hour. setUTCHours() changes the UTC clock hour. Use the one that matches your timezone rules.
getUTCHours() reads the current UTC hour. setUTCHours(h) writes a new UTC hour. They are the read/write pair for 24-hour UTC time.
24-hour format. Midnight UTC is 0, noon UTC is 12, and 11 PM UTC is 23.
JavaScript normalizes overflow into the next UTC calendar day. setUTCHours(25) rolls into 01:xx UTC on the following day.
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?
setUTCHours(15, 0, 0, 0) sets 3:00 PM UTC exactly—the same instant may show a different local hour in getHours() depending on your timezone offset.