function Fields::getTimestamp
Same name in this branch
- 11.1.x vendor/ramsey/uuid/src/Nonstandard/Fields.php \Ramsey\Uuid\Nonstandard\Fields::getTimestamp()
- 11.1.x vendor/ramsey/uuid/src/Guid/Fields.php \Ramsey\Uuid\Guid\Fields::getTimestamp()
Returns the full 60-bit timestamp, without the version
For version 2 UUIDs, the time_low field is the local identifier and should not be returned as part of the time. For this reason, we set the bottom 32 bits of the timestamp to 0's. As a result, there is some loss of fidelity of the timestamp, for version 2 UUIDs. The timestamp can be off by a range of 0 to 429.4967295 seconds (or 7 minutes, 9 seconds, and 496730 microseconds).
For version 6 UUIDs, the timestamp order is reversed from the typical RFC 4122 order (the time bits are in the correct bit order, so that it is monotonically increasing). In returning the timestamp value, we put the bits in the order: time_low + time_mid + time_hi.
Overrides FieldsInterface::getTimestamp
File
-
vendor/
ramsey/ uuid/ src/ Rfc4122/ Fields.php, line 141
Class
- Fields
- RFC 4122 variant UUIDs are comprised of a set of named fields
Namespace
Ramsey\Uuid\Rfc4122Code
public function getTimestamp() : Hexadecimal {
$timestamp = match ($this->getVersion()) { Uuid::UUID_TYPE_DCE_SECURITY => sprintf('%03x%04s%08s', hexdec($this->getTimeHiAndVersion()
->toString()) & 0xfff, $this->getTimeMid()
->toString(), ''),
Uuid::UUID_TYPE_REORDERED_TIME => sprintf('%08s%04s%03x', $this->getTimeLow()
->toString(), $this->getTimeMid()
->toString(), hexdec($this->getTimeHiAndVersion()
->toString()) & 0xfff),
Uuid::UUID_TYPE_UNIX_TIME => sprintf('%011s%04s', $this->getTimeLow()
->toString(), $this->getTimeMid()
->toString()),
default => sprintf('%03x%04s%08s', hexdec($this->getTimeHiAndVersion()
->toString()) & 0xfff, $this->getTimeMid()
->toString(), $this->getTimeLow()
->toString()),
};
return new Hexadecimal($timestamp);
}