Mongodb 文档时间字段修改

mongo文档【tblEvent】如下:

{
    "_id" : ObjectId("5a0415f9bf28b684b1c7f5b2"),
    "citycode" : 3501,
    "startTime" : ISODate("2016-01-02T00:00:00.000+0800"),
    "endTime" : ISODate("2016-12-31T23:59:00.000+0800"),
    "eType" : 2,

}

给文档startTime加一天:

db.tblEvent.find().forEach(
   function(item){                
       db.tblEvent.update({"_id":item._id},{"$set":{"startTime":new Date(item.startTime.getTime() + 1*24*60*60000)}},false,true)
     }
)

其中:

1 day = 1*24*60*60000 = 1 x 24 hours x 60 minutes x 60 seconds x 1000 milliseconds
原文地址:https://www.cnblogs.com/94cool/p/8509424.html