js date get hour code example
Example 1: javascript get time
var time = new Date();
time.getDate();
time.getDay();
time.getFullYear();
time.getHours();
time.getMinutes();
time.getSeconds();
time.getMilliseconds();
time.getTime();
time.toDateString();
time.toLocaleString();
time.toLocaleTimeString();
time.toLocaleDateString();
Example 2: javascript get hour from date
var myDate = new Date(2019, 11, 24, 10, 33);
var hour = myDate.getHours();
Example 3: javascript get 1 hour from now
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}
Example 4: js date get hours
const birthday = new Date('March 13, 08 04:20');
console.log(birthday.getHours());