SOURCE

// 找出2021-2-20至2021-3-4的日期
const fn = (start, end) => {
    start = new Date(start)
    end = new Date(end)
    let res = []
    while(start < end){
        res.push(start.toLocaleDateString().replace(/\//g, '-'))   
        start.setDate(start.getDate() + 1)
    }
    res.push(end.toLocaleDateString().replace(/\//g, '-'))
    return res
}
console.log(fn('2021-2-20', '2021-3-4'))
console 命令行工具 X clear

                    
>
console