The getHours()
method returns the hours of a date as a number (0-23):
Example
const d = new Date();
document.getElementById("demo").innerHTML = d.getHours();
document.getElementById("demo").innerHTML = d.getHours();
Practice Excercise Practice now