Minutes and seconds when the difference between two timestamps day computing

 Minutes and seconds when the difference between two timestamps day computing

/ * * 
     * ---------------------------------------------- ----------------------- 
     * calculated on the date the difference between the two time stamps every minute 
     * @param $ begin_time start timestamp 
     * @param $ end end_time timestamp 
     * @author liqiuyue 
     * ------------------------------------------- -------------------------- 
     * / 
    function timeDiff ( $ BEGIN_TIME , $ END_TIME ) {
         IF ( $ BEGIN_TIME < $ END_TIME ) {
             $ startTime = BEGIN_TIME $ ;
             $ the endtime = $ END_TIME ; 
        } the else{
             $ StartTime = $ END_TIME ;
             $ the endtime = $ BEGIN_TIME ; 
        } 

        // calculate the number of days 
        $ timeDiff = $ the endtime - $ startTime ;
         $ Days = the intval ( $ timeDiff / 86400 );
         // calculate hours 
        $ REMAIN = $ timeDiff % 86400 ;
         $ hours = the intval ( $ REMAIN / 3600 );
         // calculate the number of minutes 
        $ REMAIN = $ REMAIN%3600;
        $mins = intval($remain/60);
        //计算秒数
        $secs = $remain%60;
        $res = array("day" => $days,"hour" => $hours,"min" => $mins,"sec" => $secs);
        return $res;
    }

 

Guess you like

Origin www.cnblogs.com/bluealine/p/11058294.html