如何解决响应日期选择器在表单提交后发送到后端时会提供不需要的数据以及日期值
大家好,我使用 formik 库在 nextjs 中实现了 react-date-picker。一切似乎都很好,但是当我控制台记录日期或将其发送到我的服务器路由时。我得到了一些不需要的数据和日期。请有人建议我如何摆脱它或如何正确格式化服务器路由中的日期值。
目前,我得到如下所示的日期值
plage.Offset(1).Resize(plage.Rows.Count - 1).EntireRow.SpecialCells(xlCellTypeVisible).Delete
我想把它格式化为
2021-05-07T04:00:00.000Z
解决方法
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。