You need to record the creation time for each document in a MongoDB collection. Your first thought may be to store this information in a createdAt column, but there’s no need.

The MongoDB-generated document ID includes an embedded timestamp. You can verify this by running the following command in the mongo shell.


// ISODate("2020-07-28T16:48:35Z")