fork(3) download
  1. <?php
  2.  
  3. /* Grade de horarios com PHP
  4.  * https://pt.stackoverflow.com/questions/230713/grade-de-horarios-com-php
  5.  */
  6.  
  7.  
  8. // Comentei essas linhas apenas porque não tem acesso ao DB
  9. #$con=@mysql_connect("localhost","root","");
  10. # $bd=mysql_select_db("test",$con);
  11. //$hora_inicio = $_POST['hora_inicio'];
  12. //$hora_final = $_POST['hora_final'];
  13. $hora_inicio = "07:00";
  14. $hora_final = "10:00";
  15. $ini = strtotime($hora_inicio);
  16. $fim = strtotime($hora_final);
  17. $atu = $ini;
  18. $i = 1;
  19. for ($atu = $ini ; $atu <= $fim; $atu = strtotime('+30 minutes', $atu)) {
  20. $hr_agendamento = date('H:i', $atu);
  21. echo $hr_agendamento . "\n";
  22. // Comentei essas linha apenas porque não tem acesso ao DB
  23. # $sql = mysql_query("INSERT INTO agenda (id_agenda,hr_agendamento) VALUES('','$hr_agendamento')");
  24. }
  25. echo"agenda criada";
Success #stdin #stdout 0.01s 83904KB
stdin
Standard input is empty
stdout
07:00
07:30
08:00
08:30
09:00
09:30
10:00
agenda criada