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);
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。