php 獲取時間差

w39發表於2021-09-09


function timediff($begin_time,$end_time){     if($begin_time $end_time){        $starttime = $begin_time;        $endtime = $end_time;     }     else{        $starttime = $end_time;        $endtime = $begin_time;     }     $timediff = $endtime-$starttime;     $days = intval($timediff/86400);     $remain = $timediff%86400;     $hours = intval($remain/3600);     $remain = $remain%3600;     $mins = intval($remain/60);     $secs = $remain%60;     $res = array("day" => $days,"hour" => $hours,"min" => $mins,"sec" => $secs);     return $res;}


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/854/viewspace-2805062/,如需轉載,請註明出處,否則將追究法律責任。

相關文章