<?php
/*$a = '12:21';
$b = '17:00';
$c = '09:00';
$d = '13:53';
$t1 = convertToSeconds(getTimeDiff($a,$b));
echo "\n";
$t2 = convertToSeconds(getTimeDiff($c,$d));
echo "\n";
echo gmdate("H:i",$t1+$t2);*/
$d = 4371960;
$h = $d/3600;
$m = ($d%3600)/60;
echo "son $h:$m";
function convertToSeconds($time){
$a = explode(":", $time);
$hora = $a[0];
$min = $a[1];
return $hora*3600+$min*60;
}
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;
}
preferences:
34.62 ms | 402 KiB | 5 Q