2个时间段之前的所有日期

handleTimeQuantum(startD, endD) {
     function getDate(datestr) {
       let temp = datestr.split("-");
       let date = new Date(temp[0], temp[1], temp[2]);
       return date;
     }
     let start = startD;
     let end = endD;
     let startTime = getDate(start);
     let endTime = getDate(end);
     while (endTime.getTime() - startTime.getTime() >= 0) {
       let year = startTime.getFullYear();
       let month =
         startTime.getMonth().toString().length == 1
           ? "0" + startTime.getMonth().toString()
           : startTime.getMonth();
       let day =
         startTime.getDate().toString().length == 1
           ? "0" + startTime.getDate()
           : startTime.getDate();
       console.log(year + "-" + month + "-" + day);
       startTime.setDate(startTime.getDate() + 1);
     }
   }

你可能感兴趣的:(2个时间段之前的所有日期)