adddate是抄的网上的
var curFirstDay = new Date(inputDate.getYear(), inputDate.getMonth()); //下月开始的第一天 var nextFirstDay = addDate('5', '1', curFirstDay); //本月最后一天 var curEndDay = new Date(nextFirstDay.getTime() - 1); var obj = curEndDay.getYear() + '-' + (curEndDay.getMonth() + 1) + '-' + curEndDay.getDate(); function addDate(type, NumDay, vdate) { var date = new Date(vdate); type = parseInt(type) //类型 var lIntval = parseInt(NumDay)//间隔 switch (type) { case 6: //年 date.setYear(date.getYear() + lIntval) break; case 7: //季度 date.setMonth(date.getMonth() + (lIntval * 3)) break; case 5: //月 date.setMonth(date.getMonth() + lIntval) break; case 4: //天 date.setDate(date.getDate() + lIntval) break; case 3: //时 date.setHours(date.getHours() + lIntval) break; case 2: //分 date.setMinutes(date.getMinutes() + lIntval) break; case 1: //秒 date.setSeconds(date.getSeconds() + lIntval) break; default: } return date; }