var data = [{ version: "3.1.1", released_on: "2016-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2011-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2009-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2006-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2013-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2017-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
{ version: "3.1.1", released_on: "2015-08-21T00:00:00.000Z", high_vulns: 15, medium_vulns: 10, low_vulns: 5 },
],
ed = new Date("2016-08-21T00:00:00.000Z").getTime(),
sd = new Date("2010-08-21T00:00:00.000Z").getTime(),
result = data.filter(d => {var time = new Date(d.released_on).getTime();
return (sd < time && time < ed);
});
console.log(result);
'新的Date()。的getTime()'會給你一個數字,將是更容易 –
工作把這個瀏覽器控制檯'的console.log(新的日期(「2016 -08-21T00:00:00.000Z「))''會看到你的日期字符串是完全有效的。甚至可以直接在日期對象上使用比較運算符 – charlietfl