var aaa = function IntervalDate_Arr(startStr, endStr, interval) {
popArr = [];
var now = new Date(startStr);
var secondInt = (new Date(endStr) - now);
var days = Math.abs(secondInt / 86400000);
var freq = Math.ceil(days / interval);
var i = 0;
var thenDate = 0;
while (i <= freq) {
thenDate = new Date(now - 0 + i * interval * 86400000);
thenDate = thenDate.getFullYear() + "-" + (thenDate.getMonth() + 1) + "-" + thenDate.getDate();
popArr.push(thenDate);
i++;
}
return popArr;
}
aaa('2016-11-07', '2017-11-7', 7)
语言:js
作用:输入开始时间、结束时间、间隔时间 返回 指定的间隔日期数组
通过更改
thenDate = thenDate.getFullYear() + "-" + (thenDate.getMonth() + 1) + "-" + thenDate.getDate();
更改返回时间格式
=========================分隔符=========================
欢迎改进
不留言