Hi everyone I implemented react-date-picker in nextjs using formik library. Everything seems fine but when I console log the date or send it to my sever route. I get some unwanted data along with the date. Please, someone, suggest to me how do I get rid of it or How can I properly format the date value in the server route.
Currently, I get date value as shown below
2021-05-07T04:00:00.000Z
I want to format it as
May 7, 2021
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const date = new Date(`${req.body.date}`)
//here req.body.state returns date in ISO format
const longDate =
`${
months[date.getMonth()]}
${date.getDate()},
${date.getFullYear()
}`
//Output
May 7, 2021
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.