PHP计算时间差

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/QQ80405708/article/details/79946417
   function getTime($startdate,$enddate){
        $startdate = strtotime('2017-01-01 12:12:12');
        $enddate = strtotime('2017-01-02 13:13:13');
        $date=floor(($enddate-$startdate)/86400);
//        echo "相差天数:".$date."天<br/><br/>";
        $hour=floor(($enddate-$startdate)%86400/3600);
//        echo "相差小时数:".$hour."小时<br/><br/>";

        $minute=floor(($enddate-$startdate)%86400%3600/60);
//        echo "相差分钟数:".$minute."分钟<br/><br/>";

        $second=floor(($enddate-$startdate)%86400%3600%60);
//        echo "相差秒数:".$second."秒";
        return $date*24+$hour.'小时'.$minute.'分'.$second;
    }
阅读更多

没有更多推荐了,返回首页