3v4l.org

run code in 300+ PHP versions simultaneously
<?php $offset = strtotime('2000-01-01 00:00:00') * 1000; $time1 = floor(microtime(true) * 1000) - $offset; sleep(1); $time2 = floor(microtime(true) * 1000) - $offset; sleep(1); $time3 = floor(microtime(true) * 1000) - $offset; var_dump(sprintf('%b', $time1)); var_dump(sprintf('%b', $time2)); var_dump(sprintf('%b', $time3)); $datacenter = 1; $machine = 1; $sequence = 1; $id1 = 1 << 63 | $time1 << 22 | $datacenter << 17 | $machine << 12 | $sequence; $id2 = 1 << 63 | $time2 << 22 | $datacenter << 17 | $machine << 12 | $sequence; $id3 = 1 << 63 | $time3 << 22 | $datacenter << 17 | $machine << 12 | $sequence; var_dump(sprintf('%b', $id1)); var_dump(sprintf('%b', $id2)); var_dump(sprintf('%b', $id3)); function bin2base64($entier) { $entier = dechex($entier); $entier = hex2bin($entier); $entier = base64_encode($entier); $entier = str_replace('=', '', $entier); return $entier; } $id1 = bin2base64($id1); $id2 = bin2base64($id2); $id3 = bin2base64($id3); var_dump($id1); var_dump($id2); var_dump($id3);

preferences:
23.52 ms | 414 KiB | 5 Q