March 2018
Intermediate to advanced
592 pages
13h 44m
English
What we're going to call is .getTimestamp. The getTimestamp is a function, but it doesn't take any arguments. It simply returns the timestamp that the ObjectId was created at:
console.log(result.ops[0]._id.getTimestamp());
Now, if we go ahead and rerun our program, we get a timestamp:

In the preceding screenshot, I can see that the ObjectId was created on February 16th 2016 at 08:41 Z, so this timestamp is indeed correct. This is a fantastic way to figure out exactly when a document was created.
Now, we don't have to rely on MongoDB to create our ObjectIds. Inside of the MongoDB library, they actually give ...