I want to compare each of the dates that come from that array and compare them with today’s date, if there is a date that is equal to today’s date, let {showImage} be true:
data: [
{
id: "1",
date: "2021-10-05T00:00:00.000Z"
},
{
id: "2",
date: "2021-10-06T00:00:00.000Z"
}
]
const [showImage, setShowImage] = useState(false)
How can I make this comparison?
Note: I only want the date I don’t care about the time.
2
Answers
First make the substring and get only date from whole date object then loop over the data and compare the data date to today date here is the my approach any correction is welcome:
you can run this code in useeffect to achieve what you want.