fork download
  1. <?php
  2.  
  3. //Array com os horarios que possam ser imprimidos
  4. $hora = array('13:55:40','13:56:40','13:58:41','13:59:40','14:01:00','14:02:00','14:04:40',
  5. '14:05:00','14:07:10','14:08:00','14:10:23', '14:11:23','14:13:39','14:14:23','14:16:39',
  6. '14:17:23','14:19:13','14:20:23','14:22:40', '14:21:23','14:25:07', '14:26:23', '14:55:40');
  7.  
  8. //Intervalo que o usuario escolherá entre 3, 15, 30 ou 60
  9. $interval = 15;
  10.  
  11. $val1 = $hora[0];
  12.  
  13. print $val1;
  14.  
  15. for ($i=0;$i<(count($hora)-1);$i++) {
  16.  
  17. $val2 = $hora[$i+1];
  18.  
  19. $datetime1 = new DateTime($val1);
  20. $datetime2 = new DateTime($val2);
  21.  
  22. $intervalo = $datetime1->diff($datetime2);
  23.  
  24. $result = $intervalo->format('%i');
  25.  
  26. if($result == ($interval-1) || $result == ($interval)){
  27. print ", ".$val2;
  28. $val1 = $val2;
  29. }
  30.  
  31. }
Success #stdin #stdout 0s 83904KB
stdin
Standard input is empty
stdout
13:55:40, 14:10:23, 14:25:07