I needed a script to find the nearest quarter of the hour for a project I am working on.
Here is how I did it.
$quote = mktime(0,30,0,1,1,0)-mktime(0,15,0,1,1,0);
$thistime = time();
$thistime = round($thistime/$quote)*$quote;
$nearestQuarter = date("h:i, $thistime);