Date.prototype.getHours()
Returns the hour of a date in local time.
Syntax
date.getHours()
Returns
number — The hour, 0 through 23.
Examples
const d = new Date("2026-05-15T14:30:00");
console.log(d.getHours());
Output
14
const d = new Date("2026-05-15T00:00:00");
console.log(d.getHours());
Output
0
Notes
- Uses the 24-hour clock (0-23).
- Use `getUTCHours()` for the hour in UTC.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |