30
2018
05

PHP 微秒

  在PHP中,大多数的时间格式都是以UNIX时间戳来表示的,而UNIX时间戳是心秒为最小的计量时间的单位。这对于某些应用程序来说不够准确,所以可以调用microtime()返回当前UNIX时间戳和微秒数

mixed microtime ([ bool $get_as_float ] )

  如果给出了 get_as_float 参数并且其值等价于 TRUE,microtime() 将返回一个浮点数

<?php
    echo microtime() ."<br>";//0.72119500 1488282853
    echo microtime(true) ;//1488282853.7212
?>

  microtime()函数常用于性能分析

<?php
    date_default_timezone_set("PRC");
    $start =  microtime(true);
    for($i=0; $i<100000; $i++);
    $end = microtime(true);
    echo $end-$start;//0.0067892074584961
?>

原文链接:https://www.qiquanji.com/post/7954.html

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

微信扫码关注

更新实时通知

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。