Doc #55537 [Com]: microtime(true) reports milliseconds, not microseconds

From: Date: Thu, 01 Sep 2011 07:26:54 +0000
Subject: Doc #55537 [Com]: microtime(true) reports milliseconds, not microseconds
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7098@lists.php.net to get a copy of this message
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)

« previous php.doc.bugs (#7098) next »