Here I’ve used $toDate to convert a value to a date by multiplying it with 1000 to convert it into milliseconds.
Here UNIX timestamp is the the number of seconds between a particular date and the Unix Epoch on January 1st, 1970 at UTC
So, to convert it to BSON Date we have to multiply by 1000 because in MongoDB - “Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch on January 1st, 1970 at UTC”
After executing, it will return the following output:
You can use update query with $set operator to add new key.
collection.update(
{ ‘_id’ : “1234”},
{ “$set” : { “updated_at”: “2023-03-14 15:39:18.767232”} } )