I need the current unixtime as a round number of microseconds in a string. There’s a chance the code could run on a machine with 32 bit integers so I’d beter avoid ints. The value is used only in SQL queries, so a string will be fine.
Is it safe to use the following code?
$x = explode(' ', microtime());
$y = $x[1] . substr($x[0], 2, 6);
Is it safe to assume the coordinates of these substrings in microtime()’s return value are invariant?
Yes it is, pretty much. The string return value is there since longer time an preserved. One proposed change is to make the optional argument defaulting true, however, then you can set it to false to get the string.