How can we convert unix timestamp in MongoDB from 1619463804.069353 to Thu, 29 April 2021 4:55 PM
I tried using the following function but it doesn't work.
db.collectionname.find().forEach(function(doc){
doc['timestamp']=new Date(doc['timestamp']);
db.collectionname.save(doc);})
Also, can a similar function be used if the timestamp field is in array object?
{
_id: 1,
events: [
{
event: 1,
timestamp: '1619463804.069353',
},
{
event: 2,
timestamp: '1649463804.069353',
},
{ ... },
]
}