纵有疾风起
人生不言弃

计算程序运行时间的方法

<?php
    //定义一个run_time()方法,获取当前的时间的unix时间戳,精确到微秒;
    function run_time(){
        //microtime()函数获取当前的unix时间戳
        list($msec,$sec)=explode(” “,microtime());
        return ((float)$msec+(float)$sec);
    }
    $start_time=run_time();
    echo $start_time;
    $time1=time();
    $time2=strtotime(“2018-01-01”);
    $cha=ceil(($time2-$time1)/60/60/24);
    echo “距离2018年元旦还有<font color=’red’>{$cha}</font>天!!!<br>”;
    $end_time=run_time();
    //计算程序运行的时间
    $runtime=$end_time-$start_time;
    echo “倒计时程序运行的时间为:<font color=’blue’>”.$runtime.”</font>s”;
?>

原文链接:https://blog.csdn.net/living_ren/article/details/75081962

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

未经允许不得转载:起风网 » 计算程序运行时间的方法
分享到: 生成海报

评论 抢沙发

评论前必须登录!

立即登录