function getDuration(type,start,stop){
var $array = new Array();
var current = new Date(start);
stop = new Date(stop);
while (current <= stop) {
$array.push( new Date (current) );
if(type == 'hour'){//小时
current.setHours(current.getHours() + 1);
}else if(type == 'day'){//天
current.setDate(current.getDate() + 1);
}else if(type == 'week'){//周
current.setDate(current.getDate() + 7);
}else if(type == 'month'){//月
current.setMonth(current.getMonth() + 1);
}else{//默认天
current.setDate(current.getDate() + 1);
}
}
return $array;
}
console.log(getDuration('day','2019-10-05 10:23:16','2019-11-05 18:23:16'));
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。