MongoDB ObjectId Date Decoder
Read the creation time out of a MongoDB ObjectId. The first four bytes of the ID hold the Unix timestamp, so this shows the UTC date and time the ID was generated.
1 Fill in the box
2 Your answer
Your answer shows here as you type.
How to use the MongoDB ObjectId Date Decoder
- Paste a 24-character MongoDB ObjectId into the field. The ObjectId("...") wrapper from the mongo shell is also accepted.
- Read the Created (UTC) row for the date and time the ID was generated.
- Check the Unix timestamp, random value, and counter if you need the raw parts.
Frequently asked questions
What is inside a MongoDB ObjectId?
An ObjectId is 12 bytes, written as 24 hex characters. The first 4 bytes are a Unix timestamp in seconds, the next 5 bytes are a random value, and the last 3 bytes are a counter.
Does the timestamp include milliseconds?
No. The timestamp has whole-second precision, so the decoded time is accurate to the second.
Is the decoded date always the time a document was inserted?
Not always. The timestamp is set when the ID is generated by a driver or the server. Applications can set their own _id values, so the date may not match the insert time in those cases.
Can the timestamp be decoded without a database connection?
Yes. The timestamp is stored in the ID itself, so you only need the 24-character string to read the date.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.