Doc #55537 [Opn->Bgs]: microtime(true) reports milliseconds, not microseconds

From: Date: Wed, 31 Aug 2011 20:15:26 +0000
Subject: Doc #55537 [Opn->Bgs]: microtime(true) reports milliseconds, not microseconds
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7097@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
 Updated by:         nikic@php.net
 Reported by:        jacco at ovitech dot nl
 Summary:            microtime(true) reports milliseconds, not
                     microseconds
-Status:             Open
+Status:             Bogus
 Type:               Documentation Problem
 Package:            Documentation problem
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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.)


Previous Comments:
------------------------------------------------------------------------
[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 (#7097) next »