I am fetching data from an API in localhost. The date & time I get are in the following format:
"2021-12-08T13:52:16.043"
I just want to remove the time part and show only the date. Something like:
2021-12-08 or 2021/12/08 does not matter.
this is my code in React
{allComments.map(c=> (
<div>
<p>{c.time.toLocalDateString()}</p>
</div>
)
)}
This is not working. The error says toLocalDateString() is not a function. Thats what I found after some research. Could someone please help me with the write function and how to use it?