我的javascript数组。 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>President of USA Barack Obama is ...</p>
但我的搜索日期是var datearray = ["2010-01-10","2010-01-20","2014-01-35","2014-10-22","2014-03-02","2010-02-11","2010-03-18","2010-09-09","2014-11-12","2014-02-23","2014-03-02","2014-03-02","2014-04-22","2014-05-09","2014-02-23","","2010-02-19","2010-03-01","2010-02-27","2010-02-25"];
和startDate = 2010-01-01;
我希望在startDate和endDate之间获得新的日期数组;我是如何创造它的。
答案 0 :(得分:0)
var dateArray = ["2010-01-10","2010-01-20","2014-01-35","2014-10-22","2014-03-02","2010-02-11","2010-03-18","2010-09-09","2014-11-12","2014-02-23","2014-03-02","2014-03-02","2014-04-22","2014-05-09","2014-02-23","","2010-02-19","2010-03-01","2010-02-27","2010-02-25"],
startDate = Date.parse("2010-01-01"),
endDate = Date.parse("2010-03-29");
var filteredDateArray = dateArray.filter(function(s) {
s = Date.parse(s);
return s > startDate && s < endDate;
});
console.log(filteredDateArray);