126 of 264 menu

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

date.getHours();

Example

Let's output the current hour:

let date = new Date(); let res = date.getHours(); console.log(res);

See also

plkkidazhu