Skip to content
UUID App
Contact
UUID App
Code

How to get the timestamp from a UUID v7

Every UUID v7 starts with the moment it was created. Here is where that time hides, and how to read it in JavaScript, Python and SQL.

By The UUID App teamUpdated 2 min read

Quick answer

Take the first 12 characters of the UUID (ignoring hyphens) and read them as a hexadecimal number. That number is the creation time in milliseconds since 1 January 1970, UTC.

Try it with your own UUID

Created (UTC)23 Oct 2026, 09:30:00.000
Your timeShown in your time zone
Unix milliseconds1792747800000

Where the time lives

A UUID v7 is 128 bits. The first 48 bits, which are the first 12 hex characters, hold the time. The next digit is always 7, the version. The rest is random, apart from two bits that mark the standard layout.

  • Timestamp, 48 bits
  • Random, 74 bits
  • Version, always 7
  • Variant, 8, 9, a or b
When was this UUID made? Paste it and see the date. Decode a UUID
Need 10,000 UUIDs? Export to CSV, JSON or SQL. Try it free

Step by step

Using the example above:

  1. Remove the hyphens and keep the first 12 characters01a1681885c0
  2. Convert from hexadecimal to a normal number1792747800000
  3. Read it as milliseconds since 1 Jan 1970, UTC2026-10-23 09:30:00.000 UTC

Read it in code

JavaScript

const hex = id.replace(/-/g, '').slice(0, 12);
const created = new Date(parseInt(hex, 16));
// 2026-10-23T09:30:00.000Z

Python

from datetime import datetime, timezone
ms = int(id.replace("-", "")[:12], 16)
created = datetime.fromtimestamp(ms / 1000, tz=timezone.utc)
# 2026-10-23 09:30:00+00:00

In PostgreSQL

PostgreSQL 18 can make v7 IDs with uuidv7() and read the time back with uuid_extract_timestamp(). On older versions, parse the hex yourself:

SELECT to_timestamp(
  ('x0000' || substr(replace(id::text, '-', ''), 1, 12))
    ::bit(64)::bigint / 1000.0
) AS created
FROM users;

Good to know

Precision is one millisecond

The time comes from the machine's clock

Anyone can read it

Something missing or wrong in this guide?Tell us and we will fix it.

Need a UUID v7 right now?

Make one, or 10,000 at once.

Open the v7 generator

Keep reading