[Solved] Using Javascript how to add days and years to the current date?


It’s quite simple, create a new date, get the day and the year increase them and return a new date with the new values.

This is a DEMO returning a date increased with one day and one year from the current one.

var date = new Date();
document.write(date);
var month = date.getMonth()+1;
var day = date.getDate();
var year = date.getFullYear();

var newDate = new Date(month+"-"+(day+1)+"-"+(year+1));

document.write("<h3>"+newDate+"</h3>");

0

solved Using Javascript how to add days and years to the current date?