[eluser]Otemu[/eluser]
Great help guys, used timmahoney method in end
(edit now using InsiteFX method), added switch so 17:59 will now go to 18:00.
Code:
$minute = date("i");
$nQuarter = round($minute / 15)* 15;
switch($nQuarter) {
case 60:
$ntime = date('G', strtotime(" +1 hours"));
echo $ntime.':00';
break;
case 0:
echo date('G').':00';
break;
default:
echo date('G').':'.$nQuarter;
}
Actually looking at InsiteFX method probably works better as no need for switch
Final Code:
Code:
$ctime = date('G:i');
$minutes = 15;
$format = "G:i";
$seconds = strtotime($ctime);
$rounded = round($seconds / ($minutes * 60)) * ($minutes * 60);
echo date($format, $rounded);