3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = get_minutes('02:50'); $b = get_minutes('08:30'); /*echo intval(($b+30)/60); echo " "; echo ($b+30)%60;*/ $d = $b-$a; $intervalo = 15; $citas = intval($d/$intervalo); for($i=0;$i<$citas;$i++){ $horaCom = intval($a/60); $horaTer = intval(($a+$intervalo)/60); $minCom = $a%60; $minTer = ($a+$intervalo)%60; echo $horaCom.":".$minCom."-".$horaTer.":".$minTer."\n"; $a=$a+$intervalo; } function get_minutes($time_string) { $parts = explode(":", $time_string); $hours = intval($parts[0]); $minutes = intval($parts[1]); return $hours * 60 + $minutes; }
based on Ge4vt
Output for 4.3.0 - 7.3.0beta1
2:50-3:5 3:5-3:20 3:20-3:35 3:35-3:50 3:50-4:5 4:5-4:20 4:20-4:35 4:35-4:50 4:50-5:5 5:5-5:20 5:20-5:35 5:35-5:50 5:50-6:5 6:5-6:20 6:20-6:35 6:35-6:50 6:50-7:5 7:5-7:20 7:20-7:35 7:35-7:50 7:50-8:5 8:5-8:20