3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/Montevideo'); $hoy = date('d-m-Y H:i:s'); $hoystr = strtotime($hoy); $mañana = date('d-m-Y H:i:s',strtotime('+1 day', $hoystr)); /*echo $hoy; echo "\n"; echo $mañana; echo "\n";*/ $time = strtotime(date('H:i',$hoystr)); $otro = strtotime(date('H:i','09:00:00')); echo "hora de ingreso: ".date('H:i',$hoystr); echo "\n"; echo "hora comienzo atencion: 09:00"; echo "\n"; echo "diferencia: ".date('H:i',$otro-$time); echo "\n"; echo getTimeDiff(date('H:i',$hoystr),"09:00"); 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; }
based on 9DbQB
Output for 5.6.13 - 7.2.0
Notice: A non well formed numeric value encountered in /in/nNenC on line 12 hora de ingreso: 22:31 hora comienzo atencion: 09:00 diferencia: 19:29 10:29:00
Output for 5.4.0 - 5.6.12
Notice: A non well formed numeric value encountered in /in/nNenC on line 12 hora de ingreso: 23:31 hora comienzo atencion: 09:00 diferencia: 18:29 09:29:00