Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Date.prototype.getUTCHours: hour in UTC

getUTCHours returns the hour from 0 through 23 derived from a Date object’s time value in UTC.

Version: ECMAScript 1 onward; example target: Node.js 24.22.2

Syntax

date.getUTCHours()

date.getUTCHours() returns the UTC hour as a Number from 0 through 23. Unlike getHours(), it does not depend on the local time zone or daylight-saving rules. getUTCMinutes() and getUTCSeconds() read the corresponding smaller fields.

The method takes no arguments, does not mutate the date, and ignores extra arguments. It returns NaN for an invalid Date. A receiver without Date internal state, such as Date.prototype.getUTCHours.call({}), throws TypeError.

Use it for UTC-based protocols and calculations; for user-facing presentation, Intl.DateTimeFormat with the intended zone is usually better. The method has existed since ECMAScript 1.

Examples

const instant = new Date("2024-07-01T23:30:00-04:00");
console.log(instant.toISOString());
console.log(instant.getUTCHours(), instant.getUTCDate());
console.log(Number.isNaN(new Date(NaN).getUTCHours()));

Result

2024-07-02T03:30:00.000Z
3 2
true

Sources