Agzam Agzam - 1 year ago 124
Javascript Question

Add day(s) to a Date object

Possible Duplicate:

How to add number of days to today's date?

I'm confused, I found so many different approaches, and which of them is actually correct?

So what is the correct way to add day(s) to a given Date?

Answer Source

Be aware: this answer has issues (see comments)

var myDate = new Date();
myDate.setDate(myDate.getDate() + AddDaysHere);

It should be like

var newDate = new Date(date.setTime( date.getTime() + days * 86400000 ));

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download