期望效果如下

function getMonths(startTime, endTime) {
if (!startTime || !endTime) {
return [];
}
let months = [];
for (
let month = moment(startTime);
moment(month).isSameOrBefore(endTime, 'month');
month = month.add(1, 'month')
) {
months.push(month.month() + 1);
}
return months;
}
网友评论