how to convert timestamp to date in mongodb?

前端 未结 2 1272
一向
一向 2020-12-18 00:43

i am working on aggregation of mongodb collection.my mongodb collection has creation_time in timestamp.How will i can collect same day result and aggregate with next day res

2条回答
  •  一生所求
    2020-12-18 01:05

    In my case , I used

    db.collection.aggregate([
      { "$project": {
        "date": { "$toDate": { 
            $multiply:["$_id",1000 ]
                 } 
           }
      }}
    ])
    

    convert timestamp from milliseconds to seconds.

提交回复
热议问题