UUID Timestamp Decoder (v1, v6, v7)

UUID v1, v6 and v7 store timestamps in different layouts. Version 1 splits its 60-bit clock across fields that must be reassembled in the correct order. Paste a UUID and the decoder displays its embedded instant.

[SEC.01 // DECODE]

UUID → embedded timestamp

V1 · V6 · V7

Enter a value to see results below. Braces, URN prefix and dashes are all accepted. The 13th hex digit is the version, and only versions 1, 6 and 7 put a clock anywhere in the id.

Version —
Date (UTC) —
Unix milliseconds (ms) —
Unix seconds (s) —

v1 and v6 count 100-nanosecond intervals since 1582-10-15 (the Gregorian reform) — 12,219,292,800 seconds before the unix epoch, which is why their raw tick numbers look nothing like a unix time. v1 writes that count little-endian, so time_low comes first, and v6 rewrites it big-endian so ids sort by time. v7 skips the calendar arithmetic and stores plain unix milliseconds in the first 48 bits. NOW generates a v7 sample: the 48 time bits are real, the rest is random — it is not an id your database assigned.

[SEC.02 // THREE CLOCKS]

Three standard timestamp layouts, two epochs

RFC 4122 / 9562
VersionClockHow the bits are laid out
160-bit count of 100 ns ticks since 1582-10-15fields ordered low / mid / high: rearrange them and remove the version nibble; this is not whole-value little-endian byte order
6the same 60-bit count and the same 1582 epochthe identical value rearranged big-endian, so lexicographic order equals chronological order
748-bit Unix millisecondsthe first 12 hex digits, plainly, in the order you read them
2not usableDCE Security borrows the v1 frame but replaces part of the clock field with a local user id
3, 5nonename-based hashes (MD5 / SHA-1) — the digits that look like a timestamp are hash output
4noneRandom bits, not a timestamp
8customApplication-defined layout; may contain time, but has no universal timestamp decoding rule
  • The 1582 epoch is not a typo. UUIDv1 counts 100-nanosecond intervals from the start of the Gregorian calendar (15 October 1582), so a v1 clock value is 12,219,292,800 seconds larger than the Unix time of the same instant. That constant — 122192928000000000 ticks — is the only subtraction between the two worlds.
  • Byte order is the whole trap. The v1 layout exists because a C struct field could be read aligned on 1990s CPUs: the 60-bit counter was split with the low field written first. Sorting v1 ids as strings therefore scrambles the timeline — RFC 9562 (2024) added v6 exactly to fix that, without changing the clock.
  • Version and variant nibbles are how the widget decides. The 13th hex digit overall, at the start of the third group, is the version (…-7xxx-… is v7); the first digit of the fourth group is the variant, and RFC 4122 ids show 8, 9, a or b there.
  • v7 standardizes a millisecond clock. The 48-bit field spans roughly 8,900 years from 1970. Additional bits may contain a sub-millisecond fraction, a monotonic counter or randomness, depending on the generator. Do not infer finer timing or within-millisecond ordering without knowing that implementation.
[SEC.03 // DECODE IT YOURSELF]

The expressions, and what databases already do

HAND-ROLLED IS FINE
  • v1: ts = (time_hi_without_version << 48) | (time_mid << 32) | time_low, then unix_ms = (ts - 122192928000000000) / 10000. Note the version nibble sits inside the third field, so it must be masked off before shifting.
  • v6: ts = (time_low << 28) | (time_mid << 12) | time_hi_without_version, then the same subtraction and division. No byte swapping.
  • v7: unix_ms = 0x + the first 12 hex digits. Nothing else to do, which is why new schemas pick it.
  • PostgreSQL 18 added uuidv7() for generation and uuid_extract_timestamp(), which reads v1 and v7 (and returns NULL for every other version). On older servers there is no built-in, so decode by hand with the expressions above — or, better, keep a real timestamptz column and stop auditing ids for time.
  • Java / .NET. UUID.timestamp() (Java) returns the raw 100 ns count for v1 only and throws for other versions, including v6; on .NET Framework the field-order getters are absent, so it is the same three shifts in your own code.

Two names that look like this problem and are not: a UUID in braces or with a urn:uuid: prefix is the same 32 hex digits (the widget accepts all of them), and the 12-digit tail of an ObjectId is a different format entirely — see the MongoDB ObjectId page. If your "UUID" has 24 characters, that is the one to use.

[DOC.FAQ // INDEX]

ANSWERS

05 ITEMS
01 How do I decode the timestamp from a UUID v1?

Rearrange the clock fields back into one number: take time_low (first 8 hex), time_mid (next 4) and the 12 bits of the third group after the version nibble, compose (hi12 << 48) | (mid << 32) | low, then subtract 122,192,928,000,000,000 ticks and divide by 10,000 to get Unix milliseconds.

02 Why does UUID v1 use 1582 as its epoch?

The original Apollo/Mach UUID specification chose the start of the Gregorian calendar (15 October 1582) so that the 60-bit 100-nanosecond counter would not run out for millennia and would align with the calendar Western systems used. Unix's 1970 offset has to be subtracted out, and it always is a constant rather than a calculation.

03 What is the difference between UUIDv6 and UUIDv1?

The clock is identical — 100-nanosecond ticks since 1582-10-15 — but v6 writes it big-endian so that a string sort of the ids sorts them by time. v1 was laid out for aligned memory reads on 1990s hardware, which scrambles chronological order.

04 Can I get a date out of a UUID v4?

No. v4 is 122 random bits with only the version and variant nibbles fixed, so every field that resembles a timestamp in v1/v6/v7 is noise. If a system needs time-ordered v4-style ids it is using v7 — check the 13th hex digit.

05 How many digits of precision does UUIDv7 have?

The standard leading 48-bit field records Unix milliseconds. A generator may use additional bits for sub-millisecond fractions or monotonic counters, as well as randomness. This decoder reads the common millisecond field; finer precision and ordering require knowledge of the generator.

[SEC.MATRIX // RELATED]

Related tools

3 PAGES

Sources and specifications