I have read "Compare two dates with JavaScript" and it is helpful but does not address this issue.
This is not really about comparing dates. Instead, it is about filters being destructive.
I am using a filter in Apps Script to filter records so I only see today's records. In order for it to match. Otherwise, it would not match because the time would be different.
const today = new Date().setHours(0, 0, 0, 0);
const todayReports = formData.filter(a => a[0].setHours(0, 0, 0, 0) == today);
However, when I do this, I then lose the time completely, so I cannot then reference the time from the filtered data. I didn't realise that the filtering would be as destructive as this on the data, I thought it was just a rule to match the data, but the data would then be intact after filtering.
The .setHours in the filter actually changes the time in the original data and not just in the new filtered data in the new variable.
Any help you can give would be greatly appreciated.
EDIT: I have solved it. By setting the hours of just Today, I was then able to see if the filter date was greater than or equal to.
const today = new Date().setHours(0, 0, 0, 0);
const todayReports = formData.filter(a => a[0] >= today);