dayjs add hours code example
Example 1: javascript add minutes to date
var minutesToAdd=30;
var currentDate = new Date();
var futureDate = new Date(currentDate.getTime() + minutesToAdd*60000);
Example 2: javascript date add days
function addDays(originalDate, days){
cloneDate = new Date(originalDate.valueOf());
cloneDate.setDate(cloneDate.getDate() + days);
return cloneDate;
}
let appointment = new Date("February 12, 2021 00:00:00");
let newAppointment = addDays(appointment, 7);
console.log(appointment.getDate());
console.log(newAppointment.getDate());
Example 3: date add hours javascript
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}