# 求两个日期中间的有效日期

function rangeDay(day1, day2) {
  const result = [] // 结果数组
  const dayTimes = 24 * 60 * 60 * 1000 // 一天有多少ms
  const startTime = day1.getTime() // day1的时间戳
  const range = day2.getTime() - startTime // day1和day2相隔的毫秒数

  let total = 0 // total是代表多少天(dayTimes的整数倍)

  while (total <= range && range > 0) {
    result.push(new Date(startTime + total).toLocaleDateString()) // .toLocaleDateString()代表把时间格式2015-02-09T00:00:00.000Z转到2015-2-10
    total += dayTimes
  }

  return result
};

console.log(rangeDay(new Date("2015-02-08"), new Date("2015-03-03")))