Dealing with JSON data like the following:
[
{
"hourly_AQI": 73.0,
"hourly_date": "Tue, 31 Oct 2023 11:00:00 GMT"
},
{
"hourly_AQI": 79.0,
"hourly_date": "Tue, 31 Oct 2023 13:00:00 GMT"
},
{
"hourly_AQI": 77.0,
"hourly_date": "Tue, 31 Oct 2023 14:00:00 GMT"
}
]
I have written code that creates an array of data where the hourly_date is greater than the current local time. However, when I run the code at 18:03, it only gives me data from 13:00:00 onwards. Why is that?
const now = new Date();
const filteredData = aqiData?.filter((item) => {
const date = new Date(item.hourly_date);
// Check if the item's date is in the future
return date >= now
});
console.log(filteredData)
I also tried running the code around 1 PM, but it still returns data from 7:00 AM onwards, even though I specified greater than or equal to. I'm confused, please help!