How can I get the date after three days from today in ISO format?
I can get today's date with the following code, but not sure about how to get the ISO date in three days.
const today = new Date().toISOString().substring(0, 10);
How can I get the date after three days from today in ISO format?
I can get today's date with the following code, but not sure about how to get the ISO date in three days.
const today = new Date().toISOString().substring(0, 10);
I made this script for you, so you can actually add or substract as much hours, minutes and seconds as you want!
function strtotime(date, addTime){
let generatedTime=date.getTime();
if(addTime.seconds) generatedTime+=1000*addTime.seconds; //check for additional seconds
if(addTime.minutes) generatedTime+=1000*60*addTime.minutes;//check for additional minutes
if(addTime.hours) generatedTime+=1000*60*60*addTime.hours;//check for additional hours
return new Date(generatedTime);
}
Date.prototype.strtotime = function(addTime){
return strtotime(new Date(), addTime);
}
let futureDate = new Date().strtotime({
hours: 24 * 3, //Adding 3days
seconds: 0 //Adding 0 seconds return to not adding any second so we can remove it.
}).toISOString().substring(0, 10);
console.log( futureDate );