javascript add minutes to date
//add 30 minutes to date
var minutesToAdd=30;
var currentDate = new Date();
var futureDate = new Date(currentDate.getTime() + minutesToAdd*60000);
javascript add minutes to date
//add 30 minutes to date
var minutesToAdd=30;
var currentDate = new Date();
var futureDate = new Date(currentDate.getTime() + minutesToAdd*60000);
date add 1 hour javascript
//JS
function addHoursToDate(date, hours) {
return new Date(new Date(date).setHours(date.getHours() + hours));
}
//TS
function addHoursToDate(date: Date, hours: number): Date {
return new Date(new Date(date).setHours(date.getHours() + hours));
}
let myDate = new Date();
console.log(myDate)
console.log(addHoursToDate(myDate,2))
javascript add day to date
function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
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()); // 12
console.log(newAppointment.getDate()); // 19
date add hours javascript
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us