Convert date to timestamp mongodb
If you want to convert date to timestamp then you can use $toLong
aggregation
Post.aggregate([ { "$match": { "author_id": "uRKNnDZIv" }}, { "$addFields": { "timestamp": { "$toLong": "$created_at" } }}])
And If you want to convert timestamp to date then you can use $toDate
aggregation
Post.aggregate([ { "$match": { "author_id": "uRKNnDZIv" }}, { "$addFields": { "timestamp": { "$toDate": "$created_at" } }}])