> I apologize in advance for my constant nub questions.. > > How can I round the current time up or down to the nearest 1/2 hour? > > eg: > timeranges: > > 0900 through 0915 == 0900 > 0916 through 0930 == 0930 > 0931 through 0945 == 0930 > 0946 through 1000 == 1000 > >
I'm sure there's a better way to do this, but :
$time = {any range}
if (substr($time,2,1) > 3) { $time = "0".substr($time,0,1)+1."00"; } else { $time = "0".substr($time,0,1)."00"; }
Untested
-- Burhan Khalid phplist[at]meidomus[dot]com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php