spaze Posted November 3, 2009 Share Posted November 3, 2009 I use the following function to get microtime: function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } How can I get date and time in microseconds? Quote Link to comment Share on other sites More sharing options...
salathe Posted November 3, 2009 Share Posted November 3, 2009 You can use the date function to get the date in whatever format you like. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 3, 2009 Share Posted November 3, 2009 function microDateTime() { list($microSec, $timeStamp) = explode(" ", microtime()); return date('F jS, Y, H:i:', $timeStamp) . (date('s', $timeStamp) + $microSec); } echo microDateTime(); //Output: November 3rd, 2009, 15:38:38.671753 Modify format as needed Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 3, 2009 Share Posted November 3, 2009 Just a thought. We use microtime, to get time reading with microsecond precision, but by enclosing microtime in function, we actually delay it's execution (how much?). Wouldn't it be more logical, to call microtime externally and pass it's result to the function that would do formatting only? Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 3, 2009 Share Posted November 3, 2009 Just a thought. We use microtime, to get time reading with microsecond precision, but by enclosing microtime in function, we actually delay it's execution (how much?). Wouldn't it be more logical, to call microtime externally and pass it's result to the function that would do formatting only? Good point. I guess it depends on what the purpose is. If I was running some start and end times of a process to gather metrics on performance I would probably include the microtime call int he function itself. Since each start and stop would have to call the function, the time to start the function should be "equivalent" if not for the single instance it should be over the long term. Quote Link to comment 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.