Re: PHP Rounding Time

From: Date: Fri, 04 Apr 2003 16:43:44 +0000
Subject: Re: PHP Rounding Time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142370@lists.php.net to get a copy of this message
Jay Fitzgerald wrote:
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

« previous php.general (#142370) next »