大佬教程收集整理的这篇文章主要介绍了数据格式错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将数据从我的后端插入到 MongoDb。例如,如果我想插入“2021-06-03”,我将得到“2021-06-02T21:00:00.000+00:00”。 型号:
const organizerscheR_823_11845@a = new mongoose.scheR_823_11845@a({
description: { type: String,required: true },duration: { type: number },LOCATIOn: { type: String },date: { type: Date,default: Date.Now },
路线:
const { description } = req.body;
const { date } = req.body;
const { LOCATIOn } = req.body;
const { duration } = req.body;
const newAdd = new Add({
description,date,LOCATIOn,duration,});
试试
date: { type: Date,default: new Date() },
,
为什么不尝试使用 moment ( moment().unix() )将其保存为 unix 呢?这是一个数字,您应该能够轻松地将其转换回日期。
否则使用 moment 将其转换为正确的时区
时刻(日期).utcOffset('+0300').格式(格式)
以上是大佬教程为你收集整理的数据格式错误全部内容,希望文章能够帮你解决数据格式错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。