Link to home
Start Free TrialLog in
Avatar of niceguy971
niceguy971

asked on

Adding days to any date in javascript

How to add 31 days to the date in JavaScript?
Both dates must be in format MM/DD/YY.
Thanks
Avatar of Big Monty
Big Monty
Flag of United States of America image

try this:

var today = new Date();
var newDay = new Date();
newDay.setDate(today.getDate()+31);

Open in new window

Avatar of niceguy971
niceguy971

ASKER

Hi Big Monty, it does  Not answer my question!!! The format must be MM/DD/YY
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think this would be simpler for the formatting part....

var newDay = new Date();
newDay.setDate(newDay.getDate()+31);

var result =newDay.format("mm/dd/yy");
The getDate method will return a day between 1 and 31 (see http://www.w3schools.com/jsref/jsref_obj_date.asp).