The getHours() method returns the hour for the specified date, according to local time.
dateObj.getHours()
None.
The value returned by getHours() is an integer between 0 and 23.
getHours()The second statement below assigns the value 23 to the variable hours, based on the value of the Date object Xmas95.
var Xmas95 = new Date('December 25, 1995 23:15:30');
var hours = Xmas95.getHours();
console.log(hours); // 23
Created by Mozilla Contributors, license: CC-BY-SA 2.5