Convert date from milliseconds to ISODate object
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to aggregate records in a MongoDB colloection by hour and need to convert date stored as timestamp (milliseconds) to ISODate so that I can use aggregate framework's built-in date operators ($hour, $month, etc.) Records are stored as { "data" : { "UserId" : "abc", "ProjId" : "xyz"}, "time" : NumberLong("1395140780706"), "_id" : ObjectId("532828ac338ed9c33aa8eca7") } I am trying to use an aggregate query of following type: db.events.aggregate( { $match : { "time" : { $gte : 1395186209804, $lte : 1395192902825 } } }, { $project : {