php - How to increment a given time with a given number of minutes and associate the new time to a array list -
i need increment given time given minutes number , and associate time array list of id's. example of need :
$ids_arrays = array(699926900040821, 699926900040822, 699926900040823); $given_time='20:30'; $given_minutes = '5'; $newarray=array();
and want create new array :
array ( [699926900040821] => '20:35' [699926900040822] => '20:40' [699926900040822] => '20:45' )
my code :
//$_get['grupuri']= simple array ,$ids_arrays; //$_get['numar_grup']= number of minutes increment ; //$_get['time_grup']=time array; $ora_grup=array(); $h1=new datetime($_get['time_grup']); $m1=new dateinterval('pt'.$_get['numar_grup'].'m'); ( $i=0; $h=$h1; $h->format('h') <10; $i <count($_get['grupuri']) ; $i++, $h->add($m1)) { $ora_grup[$_get['grupuri'][$i]]=$h->format("h:i\n"); }
try this:
$ids_arrays = array('699926900040821', '699926900040822', '699926900040823'); $given_time = '20:30'; $given_minutes = '5'; $t = strtotime('today '. $given_time); $newarray = array(); foreach ($ids_arrays $id) { $newarray[$id] = date('h:i:s', $t += $given_minutes * 60); }
Comments
Post a Comment