getDaysNumber(date){ let curDate = new Date(Date.parse(date.replace(/-/g,"/")));; let y = curDate.getFullYear(); let m = curDate.getMonth() + 1;//本身就得+1才等于当前月份,然而我要计算下一个月,所以直接+2 if( m > 12 ){ m = 1; y++ }else if(m<1){ m = 12; y-- } let monthLastDay = new Date(y,m,0).getDate(); return monthLastDay; },
获取一个月的第一天和最后一天
setDate(date,number){ let curDate = new Date(Date.parse(date.replace(/-/g,"/")));; let y = curDate.getFullYear(); let m = curDate.getMonth() + number;//本身就得+1才等于当前月份,然而我要计算下一个月,所以直接+2 if( m > 12 ){ m = 1; y++ }else if(m<1){ m = 12; y-- } let monthLastDay = new Date(y,m,0).getDate(); let syqxks = y + '-' + (m < 10 ? '0'+m : m) + '-' + '01'; let syqxjs = y + '-' + (m < 10 ? '0'+m : m) + '-' + (monthLastDay < 10 ? '0'+monthLastDay : monthLastDay); return { firstday: syqxks, lastday: syqxjs } },