I have the following function which creates a component for me:
renderComments(comments){
const listcomments = comments.map((comment) => {
return (
<li key={comment.id}>
<div className="row">
{comment.comment}
</div>
<div className="row">
-- {comment.author} , {comment.date}
</div>
</li>
);
});
return(
<ul className = "list-unstyled">
{listcomments}
</ul>
);
}
My problem is that the comment.date is in a weird format: "2014-09-05T17:57:28.556094Z"
I want to change the format but just typing Date.parse({comment.date}) doesn't work (it doesn't recognize Date.parse as a function). I found on the web and in SO how to create a Date object in react by declaring a new variable, but I can't really do that inside the return right?
I am new to react so would be great if someone can help me out converting the comment.date to a normal format in an efficient way plz.