/*
*#Auth: Amit Sharma
*#Desc: Fucnction for Time difference
*#Note: use 24 hours Format only
*/
//Start from here;
<?php
//Call a function:
returnTimeDifference("10:00","14:00");
//echo returnTimeDifference("10:00","14:00");
function returnTimeDifference($dtime,$atime)
{
echo $dtime."-".$atime."
";
$nextDay=$dtime>$atime?1:0;
//use 1 to add for next day if time increases
$dep=explode(':',$dtime);
$arr=explode(':',$atime);
// echo $dep[0];
//use mktime function for two dates difference
$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')));
// echo DATE('y');//return code
echo $diff."
";
$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;
}
?>
*#Auth: Amit Sharma
*#Desc: Fucnction for Time difference
*#Note: use 24 hours Format only
*/
//Start from here;
<?php
//Call a function:
returnTimeDifference("10:00","14:00");
//echo returnTimeDifference("10:00","14:00");
function returnTimeDifference($dtime,$atime)
{
echo $dtime."-".$atime."
";
$nextDay=$dtime>$atime?1:0;
//use 1 to add for next day if time increases
$dep=explode(':',$dtime);
$arr=explode(':',$atime);
// echo $dep[0];
//use mktime function for two dates difference
$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')));
// echo DATE('y');//return code
echo $diff."
";
$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;
}
?>