Mongodb 4.0 has introduced $toLong
aggregation which convert date to timestamp
db.collection.aggregate([
{ "$project": {
"createdAt": {
"$toLong": "$createdAt"
}
}}
])
You can try it here
More Related Contents:
- Group result by 15 minutes time interval in MongoDb
- Get names of all keys in the collection
- How to filter array in subdocument with MongoDB [duplicate]
- MongoDB: Combine data from multiple collections into one..how?
- Moongoose aggregate $match does not match id’s
- Find in Double Nested Array MongoDB
- Multiple join conditions using the $lookup operator
- Conditional $sum in MongoDB
- Get a count of total documents with MongoDB when using limit
- Include all existing fields and add new fields to document
- mongodb count num of distinct values per field/key
- exclude fields in $lookup aggregation
- MongoDB aggregation comparison: group(), $group and MapReduce
- Add some kind of row number to a mongodb aggregate command / pipeline
- MongoDB group by array inner-elements
- Exception: can’t convert from BSON type EOO to Date
- Multiple Counts with single query in mongodb
- MongoDB sort documents by array elements
- How to return array of string with mongodb aggregation
- How to return just the nested documents of an array from all documents
- MongoDB: how to parse date in 3.6 mongoDb version?
- Mongodb aggregation $group, restrict length of array
- Get n-th element of an array in MongoDB
- Geospatial $near within current document field value
- How do I rename fields when performing search/projection in MongoDB?
- Mongodb aggregation pipeline how to limit a group push
- mongodb aggregation framework match by nested documents
- Mongodb concat int and string
- mongodb aggregate query isn’t returning proper sum on using $sum
- MongoDB aggregate within daily grouping [duplicate]