The examples in this article describe how JavaScript implements the number of days added for a given time. Share to everyone for your reference, specific as follows:
/** * Time Add processing function * @param date time to calculate (xxxx-xx-xx) * @param number of days to add (integer)/function calcudate (date, plusdays) {VA
R Datearray = Date.split ("-");
var year = +datearray[0];
var month = +datearray[1];
var day = +datearray[2];
var oriday = day; var secondmonthdays = ((year%4 = = 0 && year%100!== 0) | | | year%400 = 0)?
29:28;
while (plusdays>0) {oriday = Day Day = = Plusdays; Switch (month) {case 4:case 6:case 9:case 11:if (Day >) {plusdays-= (
30-oriday) +1;
month++;
Day = 1;
else {plusdays = 0;
} break;
Case 2:if (Day > Secondmonthdays) {plusdays-= (secondmonthdays-oriday) +1;
month++;
Day = 1;
else {plusdays = 0;
} break;
Default:if (Day >) {plusdays-= (31-oriday) +1;
Day = 1;
month++;
} else { plusdays = 0;
} if (month>12) {month = 1;
year++;
} Return to Createtimestring (year, month, day);
}
Of course, in addition to this approach, there are other, similar to the new date parameters such as the solution, which is a kind of
Read more about JavaScript time and date operations interested readers can view the site: "JavaScript time and date Operation Skills Summary"
I hope this article will help you with JavaScript programming.