Looking at my current array structure
const arr = [
{
id: '1', name: 'thing1', createdAt: '2022-09-21T16:26:02Z',
},
{
id: '2', name: 'thing1', createdAt: '2022-11-21T16:20:20Z',
},
];
I now aim to cycle through this array and selectively extract items that fall into the category of
createdAt >= 30 days ago from today
, ultimately providing a total count.
My initial approach involved the following code snippet:
// Assuming the date is 11/21/22
const totalOverdueCount = arr.filter((item) => DateTime.fromISO(item.createdAt).diffNow('days').days >= 30).length
Based on the dataset, I anticipate a return value of 1 (as it stands on 11/21/22). However, the outcome differs. Could there be an error in my utilization of diffNow?