Example 1 — Read the UTC Hour
Build a UTC instant with Date.UTC, then call getUTCHours().
const d = new Date(Date.UTC(2026, 2, 15, 14, 30, 0)); // 14:30 UTC
console.log(d.getUTCHours()); // 14 How It Works
- Build a UTC time.
Date.UTC(2026, 2, 15, 14, 30, 0)is March 15, 2026 at 14:30 UTC. - Wrap it in
Date.new Date(...)stores that instant. - Read the UTC hour.
getUTCHours()returns14(2 PM UTC). - No side effects. The
Dateis unchanged;getUTCHoursonly reads.

