根据时间段获取时间段内所有时间点(js)

Date.prototype.format=function (){
var s='';
s+=this.getFullYear()+'-';// 获取年份。
s+=(this.getMonth()+1)+"-"; // 获取月份。
s+= this.getDate(); // 获取日。
return(s); // 返回日期。
};
function getAll(begin,end){
var ab = begin.split("-");
var ae = end.split("-");
var db = new Date();
db.setUTCFullYear(ab[0], ab[1]-1, ab[2]);
var de = new Date();
de.setUTCFullYear(ae[0], ae[1]-1, ae[2]);
var unixDb=db.getTime();
var unixDe=de.getTime();
for(var k=unixDb+24*60*60*1000;k<unixDe;){
console.log((new Date(parseInt(k))).format());
k=k+24*60*60*1000;
}
}
快乐而轻松的写代码
原文地址:https://www.cnblogs.com/libei/p/5485011.html