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
niceguy971Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
var today = new Date();
var newDay = new Date();
newDay.setDate(today.getDate()+31);

finalMonth = newDay.getMonth() + 1;
finalDay = newDay.getDate();
finalYear = newDay.getYear();

var result = finalMonth + '/' + finalDay + '/' + finalYear;

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try this:

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

Open in new window

0
 
niceguy971Author Commented:
Hi Big Monty, it does  Not answer my question!!! The format must be MM/DD/YY
0
 
Ken ButtersCommented:
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");
0
 
Sar1973Commented:
The getDate method will return a day between 1 and 31 (see http://www.w3schools.com/jsref/jsref_obj_date.asp).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.