I haven't quite thought this through, but I think something like this:

$remainder = $ts % 60;

if( $remainder < 15 ) {
        $ts = $ts - $remainder;
}else if( $remainder > 15 && $remainder < 30 ) {
        $ts = $ts + (30 - $remainder);
}else if( $remainder > 30 && $remainder < 45 ) {
        $ts = $ts - ($remainder - 30);
}else if( $remainder >= 45 ) {
        $ts = $ts + (60 - $remainder);
}

something close to that I think...

On Fri, 4 Apr 2003, 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
>
>
> Jay Fitzgerald, Design Director
> Bayou Internet - http://www.bayou.com
> Toll Free: 888.30.BAYOU (22968)
> Vox: 318.338.2034 / Fax: 318.338.2506
> E-Mail: [EMAIL PROTECTED]
> ICQ: 38823829 / AIM: bayoujf / MSN: bayoujf / Yahoo: bayoujf
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to