function addMonth(date, num) {
num = parseInt(num);
var sDate = new Date(date);
var sYear = sDate.getFullYear();
var sMonth = sDate.getMonth() + 1;
var sDay = sDate.getDate();
var eYear = sYear;
var eMonth = sMonth + num;
var eDay = sDay;
while (eMonth > 12) {
eYear++;
eMonth -= 12;
}
var eDate = new Date(eYear, eMonth - 1, eDay);
while (eDate.getMonth() != eMonth - 1) {
eDay--;
eDate = new Date(eYear, eMonth - 1, eDay);
}
return eDate;
}
JQuery输入月份计算时间
最新推荐文章于 2022-05-11 15:23:44 发布