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();
更改返回時間格式
=========================分隔符=========================
歡迎改進
不留言