0

I have this MERN app where I have comments and as dates I use the timestamps created from the Schema "timestamps: true"

in my map function I use these for my commments and access them with .createdAt, so I can display when the comment was created at. Right now it looks like this : 2021-12-23T22:08:11.736Z

Is there a solution to convert it to 2021-12-23 in my map function?

return newArray.map((d) =>
             <div className={"commentBox"}>
                    <img src={d.profilePic} alt=""/>
                    <li className={"comment"}>
                        <div className={"commentUser"}><b>{d.username}</b>  {d.comment} <div className={"dateBox"}>{d.createdAt}</div> </div>

                    </li>

                </div>  )

0 Answers0