Skip to main content

UUIDv1

UUIDv1 is a time-based UUID that includes:

  • A 60-bit timestamp (in 100-nanosecond intervals since 1582-10-15)
  • A 14-bit clock sequence
  • A 48-bit node identifier (typically a MAC address or random bytes)

This format ensures temporal uniqueness and is ideal when you need UUIDs that reflect creation order.

Generate a UUIDv1

use DomainFlow\Uuid\UuidV1;

$uuid = UuidV1::generate();
echo (string) $uuid;

Validate a UUIDv1

$isValid = UuidV1::isValid('f47ac10b-58cc-11ec-8f4c-0242ac120002');

Metadata with Inspector

You can extract structured data from a UUIDv1 using the Inspector class:

use DomainFlow\Uuid\Inspector;

$inspector = Inspector::analyze((string) $uuid);
$metadata = $inspector->metadata();

print_r($metadata);

Typical metadata returned:

[
'timestamp_100ns' => 139856337381430000,
'clock_sequence' => 10524,
'node' => '02:42:AC:12:00:02'
]

Use Cases

  • Events that must be sorted chronologically
  • Systems that require unique IDs across machines
  • Avoiding collisions without central coordination

⚠️ Note: Since UUIDv1 embeds timestamps and node identifiers, it can potentially leak identifiable system information. If privacy is a concern, consider using UuidV4 or UuidV6.