DateTimeInterface::getMicrosecond
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.4.0)
Gets the microsecond part of the Unix timestamp
Description
DateTimeInterface::getMicrosecond(): int
DateTimeImmutable::getMicrosecond(): int
DateTime::getMicrosecond(): int
Gets the microsecond part of the Unix timestamp.
Parameters Parameters
Return Values
Returns the microsecond part of the Unix timestamp representing the date.
Examples
DateTimeInterface::getMicrosecond example
php
<?php
$date = new DateTimeImmutable('2024-01-01 12:34:56.789123');
var_dump($date->format('u'));
var_dump($date->getMicrosecond());
?>The above example will output:
output
string(6) "789123"
int(789123)See Also
DateTimeInterface::getTimestampDateTimeInterface::format