Question: I've been struggling with this for an hour or so and have come up blank. Basically I need to take the current time, add 30 minutes to it, and then round up to the next 15 minutes.

Examples:

* if it's now 20:00, result = 20:45
* if it's now 20:10, result = 20:45
* if it's now 20:16, result = 21:00
* if it's now 20:35, result = 21:15

My PHP is rusty and I've been getting mixed up with date add and round methods trying to get this to work and I know it's simple - have just run out of ideas!

Thanks

Answer: 
You may need to update this a bit and test a few scenarios where the time is close to top of the hour.

```
<?php

$now = strtotime('now');
$timePlus30 = date('H:i', strtotime('+30 minutes', $now));

$minNow = date('i', strtotime($timePlus30));
$roundedMins = $minNow + ($minNow % 15);

$return = date('H', strtotime($timePlus30)) . ':' . ($roundedMins - 1);

?>

```
not the most ellegant solution but it should work (un tested)

```
$hoursAndMins = explode(":",timeString); // should be "HH:MM"
$hours = $hoursAndMins[0]+(($hoursAndMins[1]+30)/60);
$mins = ($hoursAndMins[1]+30)%60;

if ($mins > 52){
   $mins = "00";
   $hours += 1;

}else if ($mins > 38){
    $mins = "45";
}else if ($mins > 23){
    $mins = "30";
}else if( $mins > 7){
    $mins = "15";
}else{
    $mins = "00";
}
echo $hours+ ":"+$mins;

```

[edit] The other solution is much better i think but this one is more verbose