Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reading Micro-seconds

<?php

echo (new Datetime())->format('u');
print PHP_EOL;

echo microtime(true);
print PHP_EOL;

echo hrtime(true);
print PHP_EOL;

echo date('u');
print PHP_EOL;

There are different ways to access micro seconds in PHP : use the Datetime format of u, which works with Datetime. Or call the microtime() or hrtime() functions, with the true parameter.

But don’t use date(): although it has the same u formatting letter, it never provides it.

See Also

PHP Features

Last updated: 10 September 2026