momentjs获取2个时间区间的所有时间

 

const enumerateDaysBetweenDates = (startDate, endDate) => {
      let daysList = [];
      const start = moment(startDate);
      const end = moment(endDate);
      const day = end.diff(start, "year");
      daysList.push(start.format("YYYY"));
      for (let i = 1; i <= day; i++) {
        daysList.push(start.add(1, "year").format("YYYY"));
      }
      return daysList;
    };
    
 enumerateDaysBetweenDates('2001','2005'); //['2001', '2002', '2003', '2004', '2005']

 

上一篇:go语言 格式化字符串


下一篇:java实现mysqlplus查询一个月之间的数据