PHP itself does not provide a function to return milliseconds, but it provides a microtime () function that returns an array containing two elements, a number of seconds, and a fractional number of milliseconds, which makes it easy to define a function that returns the number of milliseconds, for example:
Copy CodeThe code is as follows:
function Getmillisecond () {
List ($s 1, $s 2) = explode (", microtime ());
return (float) sprintf ('%.0f ', (Floatval ($s 1) + floatval ($s 2)) * 1000);
}
It is important to note that the Int maximum value of PHP in a 32-bit system is much smaller than the number of milliseconds, so the int type cannot be used, and PHP does not have a long type, so it has to be represented by floating-point numbers. Due to the use of floating-point numbers, if the accuracy is not set correctly, the results obtained using the echo display may not be correct, and the accuracy setting cannot be less than 13 bits if you want to see the correct output result.
http://www.bkjia.com/PHPjc/728113.html www.bkjia.com true http://www.bkjia.com/PHPjc/728113.html techarticle PHP itself does not provide a function that returns the number of milliseconds, but provides a microtime () function that returns an array of two elements, one for seconds, and one for fractional milliseconds ...