getUTCHours() returns the hour (0–23) from a Date object in UTC. This guide covers syntax, five examples, comparisons with local getters, and safe UTC time patterns.
01
Syntax
date.getUTCHours()
02
Range
0 – 23
03
UTC
24-hour
04
vs getHours
Can differ
05
Format
HH:MM UTC
06
Validate
Invalid → NaN
Fundamentals
Introduction
Servers, logs, and APIs often work in UTC. The JavaScript Date object stores one instant internally; getUTCHours() reads the hour component according to UTC, not the user’s local timezone.
If you need the hour for a greeting or clock in the user’s locale, use getHours(). Use getUTCHours() when your scheduling or reporting follows UTC boundaries.
Concept
Understanding the getUTCHours() Method
Date.prototype.getUTCHours() is a zero-argument instance method. It never mutates the original Date—it only reads the UTC hour as an integer from 0 (midnight UTC) to 23.
Pair it with getUTCMinutes(), getUTCSeconds(), and getUTCMilliseconds() for manual UTC time assembly, or use toISOString() when a full UTC string is enough.
💡
Beginner Tip
getUTCHours() returns 24-hour time only. Hour 14 means 2:00 PM UTC—not "2 PM" as a string.
Foundation
📝 Syntax
JavaScript
dateObj.getUTCHours()
Parameters
None.
Return value
Integer 0–23 for a valid date in UTC (24-hour format).
NaN if dateObj is an invalid Date.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Current UTC hour
new Date().getUTCHours()
Hour from UTC parts
new Date(Date.UTC(2026, 6, 4, 14, 30)).getUTCHours() → 14
Local hour
date.getHours()
UTC minutes
date.getUTCMinutes()
Midnight UTC check
date.getUTCHours() === 0
Valid date check
!Number.isNaN(date.getTime())
Compare
📋 getUTCHours() vs Similar Methods
UTC getters mirror local getters. Pick the one that matches where your data is displayed or stored.
getUTCHours()
0–23
UTC hour
getHours()
local
Local hour
getUTCMinutes()
0–59
UTC minute
toISOString()
…T…Z
Full UTC string
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Fixed UTC times use Date.UTC or ISO strings ending in Z for predictable results.
📚 Getting Started
Read the current UTC hour from a new Date.
Example 1 — Get the Current UTC Hour
Call getUTCHours() on the current instant.
JavaScript
const now = new Date();
const utcHour = now.getUTCHours();
console.log("UTC hour:", utcHour);
padStart(2, "0") keeps single-digit hours and minutes readable. For production, toISOString() or Intl.DateTimeFormat with timeZone: "UTC" is often simpler.
Example 5 — Compare getHours() and getUTCHours()
The same instant can show different hours in local time vs UTC.
JavaScript
const date = new Date("2026-06-15T20:30:00.000Z");
console.log("UTC hour:", date.getUTCHours()); // 20
console.log("Local hour:", date.getHours()); // depends on timezone
At 20:30 UTC on June 15, it is 02:00 on June 16 in UTC+5:30. getUTCHours() stays 20; getHours() becomes 2. Use UTC getters when cron or batch rules follow UTC.
Applications
🚀 Common Use Cases
UTC cron jobs — run tasks at a specific UTC hour.
Log timestamps — display UTC hour in debug panels.
Global dashboards — bucket traffic by UTC hour.
API windows — allow requests only during UTC business hours.
Manual formatting — build HH:MM with UTC getters.
Midnight UTC checks — detect daily rollover at hour 0.
🧠 How getUTCHours() Resolves the Hour
1
Internal instant
The Date stores milliseconds since Unix epoch (UTC).
Storage
2
UTC projection
Engine reads time fields in UTC, not local time.
UTC
3
Extract hour
UTC hour 0–23 is returned as an integer.
getUTCHours
4
🌐
Use in logic
Format, compare, or schedule against UTC hour boundaries.
Important
📝 Notes
getUTCHours() is UTC; use getHours() for local UI clocks.
Returns 24-hour integers only—not AM/PM strings.
Midnight UTC is 0, not 24.
Invalid dates propagate NaN—validate with Number.isNaN(date.getTime()).
Do not use hour getters alone to measure elapsed time—use getTime() subtraction.
For full UTC strings, toISOString() is often simpler than manual getters.
Compatibility
Browser & Runtime Support
Date.prototype.getUTCHours() has been available since the first JavaScript Date implementation (ES1). It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.getUTCHours()
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.getUTCHours()Excellent
Bottom line: Safe everywhere. Pair UTC getters together and pick UTC vs local based on your scheduling rules.
Wrap Up
Conclusion
getUTCHours() reads the hour (0–23) from a JavaScript Date in UTC. Use it for global scheduling and UTC time assembly; use local getters or locale formatters when showing clocks to end users.
An integer from 0 to 23 representing the hour in the Date object's UTC timezone. It uses 24-hour time: midnight UTC is 0, noon UTC is 12, and 11 PM UTC is 23.
getUTCHours() uses UTC rules. getHours() uses local timezone rules. They can differ when your offset shifts the hour or calendar day.
No. It always returns 24-hour format (0–23). Convert to 12-hour display yourself or use Intl.DateTimeFormat with timeZone: 'UTC'.
NaN. Validate with Number.isNaN(date.getTime()) before using the result in conditionals or UI.
Midnight UTC is 0. There is no hour 24—23 is the last hour of the UTC day.
For sending timestamps to servers, toISOString() is usually enough. Use getUTCHours() when you assemble UTC time parts manually or teach how UTC getters work.
Did you know?
At 2026-06-15T20:30:00.000Z, getUTCHours() is always 20, but getHours() can be 2 in UTC+5:30—the same instant, different hour on the clock.