Get the current time in seconds and microseconds
- August 4th, 2007
- php, Snippet-library
This function will return the current time in seconds and microseconds. This is sometimes useful to track down the processing time of a script or other short lasting events.
<p>This function will return the current time in seconds and microseconds. This is sometimes useful to track down the processing time of a script or other short lasting events.</p> <code class="prettyprint"> function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } </code> <p>An example usage could look like this:</p> <code class="prettyprint"> $start = microtime_float(); // your code here $took = round(microtime_float() - $start, 2); echo "took $took seconds."; </code>
















Submit your comment