This function will give you the current timestamp with microsecond precision.

It has two return types. By default it will return a string with the timestamp as usual and the additional microsecond part separately. This is given as a string with the two parts separated by a space (”usec sec”).

Set the second parameter to true and you get the value as a float (with decimal precision determined by your system settings).

$t1 = microtime();     // 0.93245900 1248434738
$t2 = microtime(true); // 1248434738.93

Prior to PHP 5.0 we had to do something like this to get the value as a float but the second parameter available since then takes care of this for us.

$t1 = microtime(); // 0.93245900 1248434738
list($usec, $sec) = explode(" ", $t1);
$t2 = $sec + $usec; // 1248434738.93