Generate a time-based UUID v1 using timestamp and random node ID.
Code
Utilities$time = microtime(true) * 10000000 + 0x01b21dd213814000;
$timeLow = sprintf('%08x', $time & 0xffffffff);
$timeMid = sprintf('%04x', ($time >> 32) & 0xffff);
$timeHi = sprintf('%04x', (($time >> 48) & 0x0fff) | 0x1000);
$clockSeq = sprintf('%04x', mt_rand(0, 0x3fff) | 0x8000);
$node = sprintf('%012x', mt_rand(0, 0xffffffffffff));
return sprintf('%s-%s-%s-%s-%s', $timeLow, $timeMid, $timeHi, $clockSeq, $node);Server
More PHP Snippets
Generate UUID v3
Generate a name-based UUID v3 using MD5 hashing of namespace and name.
Generate UUID v4
Generate a random UUID v4 (Universally Unique Identifier).
Generate UUID v5
Generate a name-based UUID v5 using SHA-1 hashing of namespace and name.
Generate UUID v6
Generate a reordered time-based UUID v6 with improved sortability for databases.
Generate UUID v7
Generate a Unix timestamp-based UUID v7 with millisecond precision, ideal for database primary keys.
Array Difference
Find elements in the first array that are not present in the second array.