I am trying to compare dates stored in the format 'Y-M-D H-i-s' from one array in the hopes of removing the duplicates and creating a count along side thr orignal date, I'm comparing the dates using the following code:
function compare(a, b){
if(a.getDate() == b.getDate() && a.getMonth() == b.getMonth() && a.getFullYear() == b.getFullYear()){
return true;
}else{
return false;
};
};
This is how I am looping through them:
times.forEach(function(timeOne){
times.forEach(function(timeTwo){
if(compare(timeOne, timeTwo)){
console.log("same");
}else{
console.log("different");
count.push(timeOne);
};
});
});
When I do this it does not seem to work and simply removes the first 1619 values, it does not push to the count array and causes my browser to crash. Any suggestions on how to overcome this or a better way to achieve what I need. I am also unsure at the moment on how to create the count along side.
Edit ---
Here is the remaining code for the programme:
var results = <?php echo $results; ?>,
times = [],
count = [];
results.forEach(function(result){
times.push(new Date(result.time));
});
I would also like to mention that the items array is near on 30,000 entries. So I need a way that will allow to to cut down on processing time drastically.