我正在使用https://github.com/ramsey/uuid库生成 UUID(基于时间的 v1 UUID)。
如何使用历史时间而不是当前时间从该库生成 UUID?
我有一种感觉,它与课程有关FixedTimeProvider
,类似于下面的内容,但不知道如何让它发挥作用。
$uuidFactory = new \Ramsey\Uuid\UuidFactory();
$uuidFactory->setTimeGenerator(new \Ramsey\Uuid\Generator\DefaultTimeGenerator(
new \MyVendor\Uuid\NodeProvider(),
new \MyVendor\Uuid\TimeConverter(),
new \MyVendor\Uuid\TimeProvider()
));
\Ramsey\Uuid\Uuid::setFactory($uuidFactory);
$uuid = \Ramsey\Uuid\Uuid::uuid1();
Run Code Online (Sandbox Code Playgroud)