MongoDB操作—日期转换(string、ISODate、时间戳)

1、String字符串转ISODate

db.aj_hy_copy.find().forEach(function(doc) {
doc.许可证有效期起始日期=new Date(doc.许可证有效期起始日期);
db.aj_hy_copy.save(doc);
})

2、ISODate转时间戳

db.aj_hy.find().forEach(function(doc) {
doc.许可证有效期截止日期=doc.许可证有效期截止日期.valueOf();
db.aj_hy.save(doc);
})

db后面是表名。doc.后面的是要更改的字段

猜你喜欢

转载自blog.csdn.net/qq_18769269/article/details/81557904