getHours method

The getHours method is applied to the date object and returns the value of the current hour (number from 0 to 23).

Syntax

javascriptdate.getHours();

Example

Let's output the current hour:

javascriptlet date = new Date();
let res = date.getHours();

console.log(res);

See also