Re: When is gettimeofday() or microtime() unavailable?
| From: | Nikita Popov | Date: | Fri, 12 Aug 2011 13:13:38 +0000 |
| Subject: | Re: When is gettimeofday() or microtime() unavailable? | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969383060@lists.php.net to get a copy of this message | ||
PHP on Windows provides it's own gettimeofday implementation:
http://lxr.php.net/opengrok/xref/PHP_5_3/win32/time.c#51
That's why
there aren't any problems on Windows.
On Fri, Aug 12, 2011 at 3:02 PM, Ivo F.A.C. Fokkema
<I.F.A.C.Fokkema@lumc.nl> wrote:
> Dear list,
>
> I've asked at the PHP general list also, but got no responses; perhaps
> here I have more luck.
>
> For years, I've used microtime() to get the current time including the
> microseconds. However, somebody pointed me at a sentence in the manual
> page: "This function is only available on operating systems that support
> the gettimeofday() system call."
>
> And PHP's gettimeofday() manual page suggests the same situation: "This
> is an interface to gettimeofday(2)."
>
> But... what kind of systems then don't have this system call available?
> Some googling around provided lots of C programmers trying to get a
> gettimeofday() implementation in C on Windows, since it doesn't seem to
> include it. But PHP's microtime() and gettimeofday() seem to work just
> fine on Windows (at least the boxes I could get to). Also, I just can't
> seem to find PHP code anywhere on the web that seems to check the
> existence of either microtime() or gettimeofday() before they call it,
> and there have to be lots of PHP programmers out there working on
> Windows boxes so...
>
> Should I ignore the sentence in the manual and just trust that both
> functions are always available? Or is there some other cross-platform
> way to get to the system time, including the microseconds, without using
> microtime() or gettimeofday()? Or will both functions just always exist,
> but just not give me microseconds if there is no gettimeofday() system
> call available?
>
> Any help is highly appreciated.
>
> Thanks,
>
> Ivo