PHP itself does not provide a function that returns the number of milliseconds, but it provides a microtime() function, which returns an array containing two elements, one is the number of seconds and the other is the number of milliseconds expressed as a decimal. With the help of this function, you can easily Define a function that returns milliseconds, for example:
Copy code The code is as follows:
function getMillisecond() {
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000) ;
}
It should be noted that in 32-bit systems, the maximum int value of php is far less than the number of milliseconds, so the int type cannot be used, and there is no long type in php, so you have to use float expressed in points. Due to the use of floating point numbers, if the precision setting is incorrect, the obtained results may not be displayed correctly when using echo. To see the correct output, the precision setting cannot be lower than 13 digits.
http://www.bkjia.com/PHPjc/728113.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/728113.htmlTechArticlephp itself does not provide a function that returns the number of milliseconds, but it provides a microtime() function, which returns an array , contains two elements, one is the number of seconds, the other is the millisecond expressed as a decimal...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn