js生成日期列表
function formatTime(time,spliter = '-'){
let date = new Date(time);
let year = date.getFullYear();
let month = (date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1);
let day = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate();
return `${year}${spliter}${month}${spliter}${day}`
}
var res=[]
for( let i = 1609430400000 ; i <= 1622044800000 ; ){
res.push(formatTime(i,'-'));
i += 24 * 60 * 60 * 1000;
}
网友评论