function TimeTrait::getDateTime
Returns a DateTimeInterface object representing the timestamp associated with the UUID
Return value
DateTimeImmutable A PHP DateTimeImmutable instance representing the timestamp of a time-based UUID
File
-
vendor/
ramsey/ uuid/ src/ Rfc4122/ TimeTrait.php, line 40
Class
- TimeTrait
- Provides common functionality for getting the time from a time-based UUID
Namespace
Ramsey\Uuid\Rfc4122Code
public function getDateTime() : DateTimeInterface {
$time = $this->timeConverter
->convertTime($this->fields
->getTimestamp());
try {
return new DateTimeImmutable('@' . $time->getSeconds()
->toString() . '.' . str_pad($time->getMicroseconds()
->toString(), 6, '0', STR_PAD_LEFT));
} catch (Throwable $e) {
throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e);
}
}