I am Fetching JSON data from REST APIs, in array
for (var i = 0; i < results.length; i++) {
if (results[i]["Geolocation"] != null) {
}
}
There is date field called Meeting Start date, I would like to store them in array and display as a filter, I have used below function there some issue on it
// Function helper for date humanities format
// argument csd is MeetingStartDate as .js Date() object
function hData(csd) {
if (Object.prototype.toString.call(csd) !== '[object Date]') { return 'Not Specified'; };
var tx = new Date();
tx.setMonth(tx.getMonth() - 6);
if (tx.getTime() < csd.getTime()) { return 'In last 6 Months'; };
tx = new Date();
tx.setFullYear(tx.getFullYear() - 1);
if (tx.getTime() < csd.getTime()) { return 'In last 12 Months'; };
tx = new Date();
tx.setFullYear(tx.getFullYear() - 5);
if (tx.getTime() < csd.getTime()) { return 'In last 5 Years'; };
return 'More than 5 Years';
}
I would like to filter data by In last 6 Months, In last 12 Months events on Google map
please see the image
Is there any issue or best way to do it, many thanks