Mysql
 sql >> Database >  >> RDS >> Mysql

Restituisce la differenza tra due (date e ora) PHP

Try this
function getTimes($t1, $t2)
{
$timeFirst  = strtotime($t1);
$timeSecond = strtotime($t2);
$differenceInSeconds = $timeSecond - $timeFirst;
$h=0;
$m  = floor($differenceInSeconds / 60);
$s  = $differenceInSeconds % 60;
if ($m>=60)
{
  $h = floor($m / 60);
  $m = $m % 60;
}
$tim = $h.':'.$m.':'.$s;
return $tim;
}
it will return difference time in hours:min:sec