php8.5
Home/ Manual/ datetime / datetimeinterface/ DateTimeInterface::getMicrosecond

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::getTimestamp
  • DateTimeInterface::format

Source: reference/datetime/datetimeinterface/getmicrosecond.xml · from the official PHP manual (php/doc-en)