I have a form where a user can input a date in the format mm/dd/yyyy, and we need to add an 'expiration date' that is 30 days from the date entered, regardless of calendar month, leap years, or other complex calculations.
Easy enough - first we parse out the numeric date/time object, and in this example, write it to the screen.
Then, we add 30 days (the number of days can be changed in the setting for the 'interval' variable - use a negative number to remove days)
Again, this example simply writes the date to the screen. In the current usage, I will use that date value to populate another text input in the same form as the initial date being entered.
// set number of days to add
var interval = 30;
var startDate = new Date(Date.parse(formDate));
document.write('start: ' + startDate);
var expDate = startDate;
expDate.setDate(startDate.getDate() + interval);
document.write('<br>expire: ' + expDate);
Example usage on a form input: