[PHP] Find Nearest Quarter Hour

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
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.

Code:
$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);
 
Top