how to filter data based on date in javascript code example
Example: javascript search json array for date
var startDate = new Date("2015-08-04");
var endDate = new Date("2015-08-12");
var resultProductData = product_data.filter(function (a) {
var hitDates = a.ProductHits || {};
hitDates = Object.keys(hitDates);
hitDateMatchExists = hitDates.some(function(dateStr) {
var date = new Date(dateStr);
return date >= startDate && date <= endDate
});
return hitDateMatchExists;
});
console.log(resultProductData);