0

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"

loxyboi
  • 1,078
  • 3
  • 15
  • 26
  • 1
    since you looked at the manual, did you look at the actual syntax where it says you can pass in an arg to get back a float instead of a string? and unless your system clock is absolutely wrong, there's no way to get a `0` seconds back, because that'd mean you're stuck in 1970. – Marc B Jul 07 '16 at 21:26
  • I did. But I am curious as to the string format that can be returned by default. Unless I've misinterpreted the documentation, the microseconds returned (1st value) represent the amount of microseconds elapsed since the seconds returned (2nd value) in the string. – loxyboi Jul 07 '16 at 21:30
  • 2
    microtime() is a moronically designed function, and should have never returned a string. it's basically `return str_replace($real_microtime_value, '.', ' ')` - take an internal float and bastardize it into a string. – Marc B Jul 07 '16 at 21:32
  • It certainly seems to be alright. – loxyboi Jul 07 '16 at 21:34

2 Answers2

1

The manual doesn't specify, but I just tested in PHP 5.6.11 and 7.0.6 and got the same result in both:

0.00000000 1467927441
Paul
  • 130,653
  • 24
  • 259
  • 248
1

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.

Don't Panic
  • 37,589
  • 9
  • 55
  • 71