• Count the time
  • echo getTimeDiff("10:30","11:10");
    
    function getTimeDiff($dtime,$atime)
        {
            $nextDay = $dtime>$atime?1:0;
            $dep = explode(':',$dtime);
            $arr = explode(':',$atime);
            $diff = abs(mktime($dep[0],$dep[1],0,date('n'),date('j'),date('y'))-mktime($arr[0],$arr[1],0,date('n'),date('j')+$nextDay,date('y')));
            $hours = floor($diff/(60*60));
            $mins = floor(($diff-($hours*60*60))/(60));
            $secs = floor(($diff-(($hours*60*60)+($mins*60))));
            if(strlen($hours)<2){$hours="0".$hours;}
            if(strlen($mins)<2){$mins="0".$mins;}
            if(strlen($secs)<2){$secs="0".$secs;}
            return $hours.':'.$mins.':'.$secs;
        }



    $monday = date( 'Y-m-d', strtotime( 'monday this week' ) );
    $friday = date( 'Y-m-d', strtotime( 'friday this week' ) );
     

    by kevin 6 years ago 0 Comment

0 Comment

Leave Comment