get hour from date javascript code example

Example 1: javascript make new date from hour

// Like Fri, 26 Sep 2014 18:30:00 GMT
var today = new Date();

var myToday = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);

Example 2: Date gethours js

Date.getHours()

Example 3: javascript get hour from date

var myDate = new Date(2019, 11, 24, 10, 33);
var hour = myDate.getHours();

Example 4: js date get hours

const birthday = new Date('March 13, 08 04:20');

console.log(birthday.getHours());
// expected output: 4