diff --git a/src/Generator/UnixTimeGenerator.php b/src/Generator/UnixTimeGenerator.php index 024ed51..a2615f1 100644 --- a/src/Generator/UnixTimeGenerator.php +++ b/src/Generator/UnixTimeGenerator.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Ramsey\Uuid\Generator; use Brick\Math\BigInteger; -use DateTimeImmutable; use DateTimeInterface; use Ramsey\Uuid\Type\Hexadecimal; @@ -68,7 +67,12 @@ class UnixTimeGenerator implements TimeGeneratorInterface */ public function generate($node = null, ?int $clockSeq = null, ?DateTimeInterface $dateTime = null): string { - $time = ($dateTime ?? new DateTimeImmutable('now'))->format('Uv'); + if ($dateTime === null) { + $time = microtime(false); + $time = substr($time, 11) . substr($time, 2, 3); + } else { + $time = $dateTime->format('Uv'); + } if ($time > self::$time || ($dateTime !== null && $time !== self::$time)) { $this->randomize($time);