Convert microtime to seconds php
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 49.9k10 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.1k11 gold badges69 silver badges96 bronze badges answered Dec 14, 2015 at 9:54
ahmed redaahmed reda 1432 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
Not the answer you're looking for? Browse other questions tagged php or ask your own question.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 This will produce following result − 0.60664200 1589305212 ExampleLets try to set the get_as_float value to true − Live Demo This will produce following result − 1589298812.5101 ExampleLive Demo 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 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 seconds are in a mu second?Microsecond to Second Conversion Table. What is Microtime true?microtime(true) on the other hand returns the current time in seconds since the Unix epoch accurate to the nearest microsecond (see PHP reference). It's actually very easy to test if you run the above code in a loop and display the milliseconds.
|