'How to change date format of this data structure in MongoDB?

I have some users and the structure is something like that:

{
 "_id": {"$oid":"6213baaba013b7c5f1232e25"},
 "birthDate": 239290215000,
 "surname": "Yang",
 "name": "Ruby",
 "joinDate": 1534861815000,
 "children": [
    {
     "birthDate": 876749415000,
     "surname":"Yang",
     "name":"Bob"
    },
    {
     "birthDate":926753415000,
     "surname":"Yang",
     "name":"Mel",
     "joinDate":1579005015000
    }
 ],
}

I will calculate age of user and then how long ago did they join? So I've tried to change date format but I was only able to change the format of the parents' birth dates. I could not change the format of the children's birth dates. How can I change all dates and calculate their ages? My expected output:

{
 "_id": {"$oid":"6213baaba013b7c5f1232e25"},
 "birthDate": ISODate(...),
 "surname": "Yang",
 "name": "Ruby",
 "joinDate": ISODate(...),
 "children": [
    {
     "birthDate": ISODate(...),
     "surname":"Yang",
     "name":"Bob"
    },
    {
     "birthDate": ISODate(...),
     "surname":"Yang",
     "name":"Mel",
     "joinDate": ISODate(...)
    }
 ],
}




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source