// 获取两个时间之间的月份
getMonthBetween (start, end) {
var result = [start];
var starts = start.split('-');
var ends = end.split('-');
var staYear = parseInt(starts[0]);
var staMon = parseInt(starts[1]);
var endYear = parseInt(ends[0]);
var endMon = parseInt(ends[1]);
while (staYear <= endYear) {
if (staYear === endYear) {
while (staMon < endMon) {
staMon++;
result.push(staYear + '-' + staMon);
}
staYear++;
} else {
staMon++;
if (staMon > 12) {
staMon = 1;
staYear++;
}
result.push(staYear + '-' + staMon);
}
}
return result;
},
输出 ['2018-09','2018-10']
获取两个时间之间的月份
最新推荐文章于 2023-07-30 16:31:18 发布