我正在尝试创建一个包含嵌套数组的月份数组,其中该月的所有日期都在 JavaScript 和 MomentJS 的日期范围之间。
旨在实现:如果我的日期范围是 5 月 1 日至 6 月 3 日
使用这个循环,我可以成功地构建一个天数数组,但我不能将它们分成几个月..
while (currentDate <= endDate) {
currentDate.setDate(currentDate.getDate() + 1);
dates.push(new Date(currentDate));
[May - month name
1st May - date object for day
2nd May
3rd May
4th May
...]
June
[1st June
2nd June
3rd June]
任何帮助将不胜感激!