WolfRage Posted July 19, 2009 Share Posted July 19, 2009 What is more precise microtime() or microtime(TRUE)? I know that microtime() is measured in microseconds. What is microtime(TRUE) as a unit of measurement? Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/ Share on other sites More sharing options...
metrostars Posted July 19, 2009 Share Posted July 19, 2009 Same the 1st means it is returned like 123456 12 the TRUE bit returns in like 12.123456 the first does it in microseconds followed by seconds. Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878216 Share on other sites More sharing options...
Daniel0 Posted July 19, 2009 Share Posted July 19, 2009 Neither. They're just formatted differently. Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878217 Share on other sites More sharing options...
WolfRage Posted July 19, 2009 Author Share Posted July 19, 2009 How would I compare two out puts in either format to get the exact time difference? Please elaborate on which piece means which. Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878224 Share on other sites More sharing options...
.josh Posted July 19, 2009 Share Posted July 19, 2009 They both return the same info, but in a different format. It's like the date. July 19, 2009 is the same thing as 2009-07-19. It's just formatted differently. Get it? Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878226 Share on other sites More sharing options...
WolfRage Posted July 19, 2009 Author Share Posted July 19, 2009 Never mind don't know why I wasted my time. Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878229 Share on other sites More sharing options...
.josh Posted July 19, 2009 Share Posted July 19, 2009 Don't blame us if you aren't understanding. microtime() and microtime(true) both return the same thing, only in a different format. So it's not a matter of which one is more precise, but a matter of how you want the result to be formatted. Do you want it in "seconds.microseconds" ex: 123.456 or "microseconds seconds" 456 123 what part of that don't you understand? Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878236 Share on other sites More sharing options...
thebadbad Posted July 19, 2009 Share Posted July 19, 2009 And if you're still wondering how to compare the two formats, you can simply add the two parts returned by microtime() to get a float, since they're both in units of seconds (metrostars and CV were a bit off on that part ). From the manual: list($usec, $sec) = explode(' ', microtime()); $float = ((float) $usec + (float) $sec); $float can then be directly compared to what's returned by microtime(true). Quote Link to comment https://forums.phpfreaks.com/topic/166534-solved-what-is-more-precise-microtime-or-microtimetrue/#findComment-878269 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.