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?
prototype. getDay() The getDay() method returns the day of the week for the specified date according to local time, where 0 represents Sunday.
To check if two dates are the same day, call the toDateString() method on both Date() objects and compare the results. If the output from calling the method is the same, the dates are the same day.
var today = new Date(); var tomorrow = new Date(); tomorrow. setDate(today. getDate()+1);
date.setTime( date.getTime() + days * 86400000 );
Note : Use it if calculating / adding days from current date.
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 ));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With