Get the timestamp from a MongoDB ObjectId
When you want to extract the timestamp from a MongoDB ObjectId, you can use the following method:
const objectId = new ObjectId('yourObjectIdHere');
const timestamp = objectId.getTimestamp();
console.log(timestamp);
or
ObjectId().getTimestamp();
This will give you the timestamp of when the ObjectId was created.