Doc #55537 [Com]: microtime(true) reports milliseconds, not microseconds
Edit report at https://bugs.php.net/bug.php?id=55537&edit=1
ID: 55537
Comment by: jacco at ovitech dot net
Reported by: jacco at ovitech dot nl
Summary: microtime(true) reports milliseconds, not
microseconds
Status: Bogus
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Well, that is still a documentation issue if you ask me.
Maybe a note about this could be added to the documentation?
Previous Comments:
------------------------------------------------------------------------
[2011-08-31 20:15:26] nikic@php.net
If you print floats in PHP you won't get all digits printed out (as floats are very imprecise
there could be many digits, infinitely many). If you want to see more digits you can use
number_format. For eight digits after the comma you can use number_format(microtime(true), 8,
'.', '')) for example. (Please note though that printing more digits won't
necessarily give you a more precise number, again because of floating point precision.)
------------------------------------------------------------------------
[2011-08-30 10:39:12] jacco at ovitech dot nl
Description:
------------
---
From manual page: http://www.php.net/function.microtime%23Return%20Values
---
When using the argument $get_as_float with value TRUE, the returned result has a precision of
milliseconds instead of microseconds
Test script:
---------------
<pre><?php
echo ' time(): '.time()."\n";
echo 'microtime(true): '.microtime(true)."\n";
echo ' microtime(): '.microtime()."\n";
Expected result:
----------------
time(): 1314699839
microtime(true): 1314699839.77298801
microtime(): 0.77288801 1314699839
Actual result:
--------------
time(): 1314699839
microtime(true): 1314699839.7729
microtime(): 0.77288801 1314699839
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55537&edit=1
Thread (4 messages)