Timestamps by version
| Version | Timestamp basis | Resolution | Epoch |
|---|---|---|---|
| v1 | 60-bit count of 100-ns intervals | 100 ns | 1582-10-15 |
| v6 | Same as v1, reordered for sorting | 100 ns | 1582-10-15 |
| v7 | 48-bit Unix milliseconds | 1 ms | 1970-01-01 |
| ULID | 48-bit Unix milliseconds | 1 ms | 1970-01-01 |
| v4 | None | — | — |
Decoding v1
A v1 UUID stores the timestamp in three non-contiguous groups: the low 32 bits in the first group, the middle 16 bits in the second, and the high 12 bits in the third. You must reassemble them before applying the 1582 epoch offset and dividing by 10,000 to get Unix seconds.
// time_low, time_mid, time_hi are the first three groups
const ticks = (time_hi << 48) | (time_mid << 32) | time_low;
const unixMs = (ticks / 10000) - 12219292800000; // 1582 -> 1970 offset in ms
Decoding v7 and ULID
For v7, the first 48 bits are already Unix milliseconds: take the first 12 hex digits, strip the hyphen, and parse as a number. For ULID, decode the first 10 Crockford base32 characters to the same 48-bit millisecond value.
A decoded timestamp is not proof of creation time. A caller can supply any UUID it likes; treat the decoded time as untrusted metadata unless the ID was generated by your system.