JavaScriptDategetHours

Returns the hour (0-23) in the specified date.

Syntax

date.getHours()

Example

Enter values below to update the example in real time.

const
new
console
getHours
const date = new Date();
console.log(date.getHours());   // current hour (0-23)