fork(7) download
  1. <?php
  2.  
  3. function listaHorarios($horaInicio, $horaFinal) {
  4. $secsInicio = strtotime($horaInicio) - strtotime('today');
  5. $secsFinal = strtotime($horaFinal) - strtotime('today');
  6.  
  7. $formato = function ($horario) {
  8. return date('g:ia', $horario);
  9. };
  10.  
  11. $horarios = range($secsInicio, $secsFinal, 900);
  12. return array_map($formato, $horarios);
  13. }
  14.  
  15. $horaInicio = '08:00:00';
  16. $horaFinal = '15:00:00';
  17.  
  18. $horarios = listaHorarios($horaInicio, $horaFinal);
  19.  
  20. foreach($horarios as $horario){
  21. echo "$horario \n";
  22. }
  23.  
  24.  
  25.  
  26.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
8:00am 
8:15am 
8:30am 
8:45am 
9:00am 
9:15am 
9:30am 
9:45am 
10:00am 
10:15am 
10:30am 
10:45am 
11:00am 
11:15am 
11:30am 
11:45am 
12:00pm 
12:15pm 
12:30pm 
12:45pm 
1:00pm 
1:15pm 
1:30pm 
1:45pm 
2:00pm 
2:15pm 
2:30pm 
2:45pm 
3:00pm