Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/05/2014, 08:32
lolainas
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: sumando minutos en un for

Debes sacar la fecha fuera, si no la vuelves a crear con 01:00:

Código PHP:
Ver original
  1. function agregar(DateTime $time, $cant = 4) {
  2.     $horas = array();
  3.     for ($i = 0; $i < $cant; $i++) $horas[$i] = $time->modify('+15 minutes')->format('h:i:s');
  4.     return $horas;
  5. }
  6.  
  7. $response = agregar(new DateTime("01:00"));
  8. echo json_encode($response, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);