UUID v7 timestamp decoder
Paste a UUID to read the time inside it. Version 7 stores Unix milliseconds; versions 1 and 6 store 100-nanosecond ticks since 1582.
Where the time sits in a UUID v7
A UUID v7 starts with a 48-bit big-endian count of milliseconds since 1970-01-01 UTC. Those are the first 12 hex digits, before and across the first dash. The next 4 bits are the version (7), and the rest is random data with 2 variant bits.
| Bits | Field | In the RFC example |
|---|---|---|
| 0–47 | unix_ts_ms: Unix time in milliseconds | 017F22E279B0 |
| 48–51 | Version | 7 |
| 52–63 | rand_a | CC3 |
| 64–65 | Variant | 10 (binary) |
| 66–127 | rand_b | … |
Worked example
RFC 9562 uses 017F22E2-79B0-7CC3-98C4-DC0C0C07398F as its test vector.
- Take the first 12 hex digits without the dash:
017F22E279B0. - Read them as one hexadecimal number:
1645557742000milliseconds. - Convert to a date: 2022-02-22T19:22:22.000Z, which is 2:22:22 PM in US Eastern time, as the RFC states.
UUID v1 and v6
Versions 1 and 6 count 100-nanosecond intervals since 1582-10-15, the start of the Gregorian calendar. Version 1 splits that 60-bit count into three pieces and stores them low part first, so a v1 UUID does not sort by time. Version 6 stores the same count high part first, so it sorts correctly.
The RFC's v1 example C232AB00-9414-11EC-B3C8-9F6BDECED846 and v6 example 1EC9414C-232A-6B00-B3C8-9F6BDECED846 hold the same count, 0x1EC9414C232AB00 (138648505420000000). Subtract the 122192928000000000 intervals between 1582 and 1970, divide by 10,000,000, and you get Unix time 1645557742, the same moment as the v7 example.
Code
JavaScript (UUID v7)
const uuid = '017f22e2-79b0-7cc3-98c4-dc0c0c07398f';
const ms = parseInt(uuid.replace(/-/g, '').slice(0, 12), 16);
new Date(ms).toISOString(); // '2022-02-22T19:22:22.000Z'
Python (v1, v6 and v7)
import uuid
from datetime import datetime, timezone
u = uuid.UUID('017f22e2-79b0-7cc3-98c4-dc0c0c07398f')
if u.version == 7:
ms = u.int >> 80
print(datetime.fromtimestamp(ms / 1000, timezone.utc))
elif u.version in (1, 6):
# UUID.time is the 60-bit count of 100 ns intervals since 1582-10-15
# (correct for v6 only on Python 3.14 and later; older versions read v6 as v1)
print(datetime.fromtimestamp((u.time - 0x01B21DD213814000) / 1e7, timezone.utc))
PostgreSQL 18+
SELECT uuid_extract_timestamp('017f22e2-79b0-7cc3-98c4-dc0c0c07398f');
-- 2022-02-22 19:22:22+00 (versions 1 and 7; returns NULL for others)
UUID v4 is fully random and holds no time. The decoder above says so if you paste one.
Source: RFC 9562, Universally Unique IDentifiers (UUIDs)
Source: PostgreSQL: UUID functions
Last updated: