JS获取下个月的第一天和最后一天

    /*获取下个月的第一天*/nextMonthFirstDay() {var time = new Date();var year = time.getFullYear();var month = time.getMonth() + 2;if (month > 12) {month = month - 12;year = year + 1;}var day = 1;return year + ',' + month + ',' + day;},
    /*获取下个月的最后一天*/nextMonthLastDay() {var time = new Date();var year = time.getFullYear();var month = time.getMonth() + 2;if (month > 12) {month = month - 12;year = year + 1;}var day = this.nextMonthDay(year, month);return year + ',' + month + ',' + day;},nextMonthDay(year, month) {//判断每月多少天var day31 = [1, 3, 5, 7, 8, 10, 12];var day30 = [4, 6, 9, 11];if (day31.indexOf(month) > -1) {return 31;} else if (day30.indexOf(month) > -1) {return 30;} else {if (this.isLeapYear(year)) {return 29;} else {return 28;}}},isLeapYear(year) {//判断是否为闰年return (year % 4 == 0) && (year % 100 != 0 || year % 400 == 0);},

 

本文链接:https://my.lmcjl.com/post/1180.html

展开阅读全文

4 评论

留下您的评论.