API Reference › Uuid › Uuid.new_v7
method

Uuid.new_v7

Uuid.new_v7() -> string

Generates a new **v7** (time-ordered) UUID. Its leading 48 bits are a Unix-millisecond timestamp, so a batch of v7 IDs sorts lexicographically by creation time — which keeps database indexes and append-only logs tidy in a way random v4 IDs do not. The remaining bits are secure random, so IDs minted in the same millisecond are still distinct, and the RFC 4122 version (7) and variant bits are set.

Sub-second resolution is derived from the wall clock in seconds (multiplied to milliseconds), so ordering is guaranteed at one-second granularity with the random tail breaking ties within a second. Like v4 this reads the non-deterministic wall clock and CSPRNG — generate at the edges, never inside reproducible simulation. Uuid.v7 is an alias.

Example

program NewV7 {
  entry {
    let id = Uuid.new_v7()
    print(id[14..15])   # 7 — the version nibble
  }
}
← All symbols