phpmicrotime

PHP microtime - microseconds format


If PHP's microtime() function were to be executed at a point in time where the resulting microseconds are zero, what format does it result in?

Would it look like this?

0.00 1467926279?

Or this?

0 1467926279

The manual doesn't provide a numerical format, just it's format in English:

By default, microtime() returns a string in the form "msec sec"


Solution

  • It is set to display eight decimal places here.

    snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec);
    

    so a zero for the microseconds part should always look like 0.00000000.