Doc #55537 [Bgs]: microtime(true) reports milliseconds, not microseconds
Edit report at https://bugs.php.net/bug.php?id=55537&edit=1
ID: 55537
Updated by: salathe@php.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:
See also, the "precision" php.ini setting [1], which will be currently set to 14.
If you want more digits in the float value from microtime() (or any float!) then
change that setting.
[1] php.net/ini.core#ini.precision
Previous Comments:
------------------------------------------------------------------------
[2011-09-01 07:26:54] jacco at ovitech dot net
Well, that is still a documentation issue if you ask me.
Maybe a note about this could be added to the documentation?
------------------------------------------------------------------------
[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)