Want to write a date of the addition and subtraction method, but it involves the judgment of the days of the month, if it is February, but also related to the judgment of leap years, some complex, the application process is always a problem, so check the data, in order to add on a certain date to reduce the number of days You can actually call the setdate () function of the Date object as follows:
function Adddate (date,days) {
var d=new date (date);
D.setdate (D.getdate () +days);
var month=d.getmonth () +1;
var day = D.getdate ();
if (month<10) {
month = "0" +month;
}
if (day<10) {Day
= ' 0 ' +day;
}
var val = d.getfullyear () + "+month+" "+day;
return val;
}
Where the date parameter is to be added and minus dates, format yyyy-mm-dd,days parameter is the number of days to add and subtract, if the forward calculation on the incoming negative numbers, then the incoming positive numbers, if it is to carry out the month of addition and subtraction, call Setmonth () and getmonth () on it, Note that the returned month is calculated starting at 0, which means that the returned month is one months less than the actual month, so add 1 accordingly.
Special: Note that when the combination of month and day, not directly +, will be as int type sum, to convert to string.