MongoDB ObjectId to Date Converter
The first 4 bytes of every ObjectId are the seconds since the Unix epoch when the document was inserted. That makes the humble _id field a free creation date for the millions of MongoDB documents that were saved without one.
- ✓You inherited a MongoDB collection with no createdAt field and need to sort or audit by age.
- ✓A single ObjectId from an error message needs dating — fast, without opening a shell.
- ✓One caveat: any 24-character hex string looks like an ObjectId, so matches outside MongoDB data can be false positives.
- ✓Our extractor dates ObjectIds in bulk from pasted exports and labels the 24-hex caveat right on the page.
FAQ
How do I get the date from an ObjectId manually?
Take the first 8 hex characters, parse them as a hexadecimal integer — that is seconds since 1970-01-01 UTC. Multiply by 1000 for a JavaScript-style millisecond timestamp.
Is the ObjectId timestamp the document creation time?
It is the moment the ObjectId was generated, which in practice is when the document was created on the client that inserted it. If an app supplies its own _id values, all bets are off.
Why does the tool warn about 24-hex strings?
Hashes, keys and other data can also be 24 hex characters. The tool decodes them as ObjectIds on a best-effort basis, which is why the toggle to exclude them exists.