ObjectId ↔ Timestamp converter
A MongoDB ObjectId embeds its creation time in its first 4 bytes. Paste one to extract that timestamp, or convert a date the other way. Runs entirely in your browser — nothing is sent anywhere.
ObjectId → Timestamp
Timestamp → ObjectId
How an ObjectId encodes time
A MongoDB ObjectId is 12 bytes (24 hex characters): a 4-byte Unix timestamp (seconds), a 5-byte random value unique to the process, and a 3-byte incrementing counter. Only the first 4 bytes are extracted here — the rest can't be reversed into anything meaningful, since they're random by design.
Annotated example
Take the ObjectId 507f1f77bcf86cd799439011:
| Bytes | Hex | Meaning |
|---|---|---|
| 0–3 (4 bytes) | 507f1f77 | Unix timestamp — 0x507f1f77 = 1,350,609,783 s → 2012-10-19T08:36:23 UTC, second-level precision |
| 4–8 (5 bytes) | bcf86cd799 | Random value unique to the generating process — not decodable |
| 9–11 (3 bytes) | 439011 | Incrementing counter — not decodable |
Paste the full 24-character hex string — only the first 8 characters are read. The rest are discarded.
What the timestamp actually tells you
The timestamp records when the ObjectId was created — typically at insert time, but not always. Some drivers let you construct an ObjectId with an arbitrary value, and an ID could be assigned at import time, by an external system, or after a delay. Don't treat it as an authoritative record of when a business event happened or when data was committed to disk.
Precision is second-level only. Client clock skew also affects the value — if the generating machine's clock drifts, the embedded timestamp reflects that drift.
The reverse generator on this page produces a synthetic ObjectId — only the first 8 hex characters are set from your date. The remaining 16 characters are randomly generated and are not tied to any real process, machine, or counter. Do not use generated IDs in production documents.
Accepted timestamp inputs
The converter accepts several formats:
- ISO date string — e.g.
2024-01-15T10:30:00Zor2024-01-15; any string parseable bynew Date()is accepted - Unix seconds — an integer of 10 or fewer digits, e.g.
1705312200 - Unix milliseconds — an integer of 11 or more digits, e.g.
1705312200000
Valid range: 1 January 1970 – 7 February 2106 UTC (the limits of a 32-bit unsigned Unix timestamp).
Reference: MongoDB ObjectId documentation ↗