getHours()

ES1+

Returns the hour (0-23) in the specified date according to local time.

Syntax

date.getHours()

Return Value

number

A number (0-23) representing the hour

Examples

JavaScript
const date = new Date('2024-01-15T14:30:00');
console.log(date.getHours());
Output:
// 14

Related Methods