I have the store start time as microtime() and end time as microtime() into database. Show Now I want to calculate how long the script takes the seconds/minutes/hours to execute. How can I do in PHP? asked Jun 24, 2011 at 12:59
0 basically, like this:
EDIT: you could do all the calculation on your own, too. it's just basic math like this:
danronmoon 3,7045 gold badges33 silver badges56 bronze badges answered Jun 24, 2011 at 13:03
oezioezi 50k10 gold badges97 silver badges115 bronze badges 5 microtime to seconds or hours or min conversion? microtime is the name of the php function that return a measure of time in microseconds and basically microseconds can be converted to: 1 milliseconds = 1,000 microseconds 1 second = 1,000,000 microseconds 1 minute = 60,000,000 microseconds 1 hour = 3,600,000,000 microseconds or 1 microsecond = 0.001 milliseconds 1 microsecond = 0.000001 seconds 1 microsecond = 0.0000000166666667 minutes 1 microsecond = 0.000000000277777778 hours
answered Sep 6, 2013 at 12:33
user2754369user2754369 2212 silver badges2 bronze badges
Giacomo1968 25.2k11 gold badges69 silver badges97 bronze badges answered Dec 14, 2015 at 9:54
ahmed redaahmed reda 1532 silver badges5 bronze badges If you have a time
If you want to format this number of seconds, you can use
answered Jun 24, 2011 at 13:04
Definition and UsageThe microtime() function returns the current Unix timestamp with microseconds. By default, this function returns a string value which contains microseconds and seconds separated by space (msec sec). Syntaxmicrotime($get_as_float) Parameters
Return ValuesPHP microtime() function returns the current Unix timestamp. By default this returns a string value in the form msec sec. If you pass the boolean value true as a parameter to this method, it returns the current time in seconds since the Unix epoch accurate to the nearest microsecond. PHP VersionThis function was first introduced in PHP Version 4 and, works with all the later versions. ExampleFollowing example demonstrates the usage of the microtime() function − Live Demo <?php $time = microtime(); print($time); ?> This will produce following result − 0.60664200 1589305212 ExampleLets try to set the get_as_float value to true − Live Demo <?php $time = gettimeofday(true); print_r($time); ?> This will produce following result − 1589298812.5101 ExampleLive Demo <?php $time_start = microtime(true); usleep(100); $time_end = microtime(true); $time = $time_end - $time_start; echo "Did nothing in $time seconds\n"; ?> This produces the following result − Did nothing in 0.0018141269683838 seconds php_function_reference.htm Is microtime in seconds?By default, microtime() returns a string in the form "msec sec", where sec is the number of seconds since the Unix epoch (0:00:00 January 1,1970 GMT), and msec measures microseconds that have elapsed since sec and is also expressed in seconds as a decimal fraction.
What is Microtime true in PHP?PHP microtime() function returns the current Unix timestamp. By default this returns a string value in the form msec sec. If you pass the boolean value true as a parameter to this method, it returns the current time in seconds since the Unix epoch accurate to the nearest microsecond.
How many microseconds μs are in 3 seconds?Microsecond to Second Conversion Table. What is microtime?Definition of microtime
: a very short interval of time (as 0.01 millionth of a second) microtime photography.
|