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
-
the
getDaymethod
that gets the day of the week -
the
getFullYearmethod
that gets the year -
the
getMonthmethod
that gets the month -
the
getDatemethod
that gets the day of the month -
the
getMinutesmethod
that gets the minutes -
the
getSecondsmethod
that gets the seconds -
the
getMillisecondsmethod
that gets the milliseconds