A colleague asked me today how you can convert an epoch (number of milliseconds since 1970/1/1) to a proper ISODate format. The answer comes from date math:

db.coll.aggregate({$addFields:{

date:{$add:[

ISODate("1970-01-01T00:00:00Z"),

"$epoch"

]}

}})

Because $add supports adding numbers to date (treating the number as milliseconds) we get back a proper ISODate that the number in "epoch" field represents!