getters

Date.prototype.getHours

Returns the hour of the date in LOCAL time as an integer from 0 to 23. Companion methods getMinutes, getSeconds, and getMilliseconds work the same way for their respective units.

date.getHours()

Parameters

Parameter Purpose
() no arguments; returns 0-23
local time use getUTCHours for UTC hour

Examples

console.log(new Date('2026-07-19T15:30:00Z').getUTCHours()); // 15

24-hour clock

const d = new Date(); console.log(`${d.getHours()}:${String(d.getMinutes()).padStart(2,'0')}`);

HH:mm local

console.log(new Date('2026-07-19T23:59:59Z').getUTCHours()); // 23

midnight is 0, not 24

Gotcha

Uses 24-hour clock (0-23). Local hour depends on the host timezone and DST, so the same instant returns different values on different machines.

Related

← All JS Date methods · Math methods · Cron syntax