1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
var
start =
"2017-5-25"
;
var
end =
"2017-6-5"
;
var
startTime =
new
Date(start);
var
endTime =
new
Date(end)
var
timeArr = [];
var
weekDay = [
"1"
,
"2"
,
"3"
]
while
((endTime.getTime()-startTime.getTime())>=0){
var
year = startTime.getFullYear();
var
month = startTime.getMonth().toString().length==1?
"0"
+(startTime.getMonth() + 1).toString():startTime.getMonth() + 1;
var
day = startTime.getDate().toString().length==1?
"0"
+startTime.getDate():startTime.getDate();
var
date = year+
"-"
+month+
"-"
+day;
for
(
var
i = 0;i < weekDay.length; i++){
if
(
new
Date(date).getDay() == weekDay[i]){
timeArr.push(date);
}
}
console.log(date);
startTime.setDate(startTime.getDate()+1);
}
console.log(timeArr);
|
本文转自 小旭依然 51CTO博客,原文链接:http://blog.51cto.com/xuyran/1932175