Function: getMonths

getMonths(start, end): string[]

获取两个日期之间的所有月份

Parameters

Name Type Description
start Date 开始时间
end Date 结束时间

Returns

string[]

  • 包含所有月份的数组,格式为'YYYY-M'

Example

const months = getMonths(new Date('2018-1-29'), new Date('2018-9-29'));
console.log(months); // 输出: ['2018-1', '2018-2', '2018-3', '2018-4', '2018-5', '2018-6', '2018-7', '2018-8', '2018-9']
ON THIS PAGE