I tried Google, php.net and php mailing list archives, but I can not find what I am looking for. Maybe this is obvious, or maybe no one wonders about this ...
For many years, I used microtime () to get the current time, including microseconds. However, someone pointed me to a suggestion in the page manual: "This function is only available on operating systems that support the gettimeofday () system call.
And PHP gettimeofday () offers the same situation: "This is the interface for gettimeofday (2)."
But ... which systems then do not have this system call? Some search engines offer many C programmers trying to get gettimeofday () in C on Windows since it doesn't seem to turn it on. But PHP microtime () and gettimeofday () seem to work just fine on Windows (at least boxes can get). Also, I just can't seem to find the PHP code anywhere on the Internet that seems to check for either microtime () or gettimeofday () before they call it, and there should be a lot of PHP programmers working there there are Windows Boxes, so ...
Should I ignore the suggestion in the manual and simply trust that both functions are always available? Or is there another cross-platform way to get system time, including microseconds, without using microtime () or gettimeofday ()? Or both functions will always exist, but just donβt give me microseconds if there is no gettimeofday () system a call is available?
EDIT 1:
http://www.php.net/microtime
"Returns the current Unix timestamp with microseconds. This function is only available on operating systems that support the gettimeofday() system call."
Perhaps this clarifies my point a bit.
source share