Re: [OFF: logical question] rounding in steps of 15

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/18/05, Norbert Wenzel <mail@xxxxxxxxxxxx> wrote:
> Excuse me, I know my question is not PHP specific, but I hope there are
> some logical and mathematical talents in here, since I've always been
> fighting with maths. ;-)
> 
> I have to provide a textfield, where workers enter their time they
> worked on a certain subject. The smallest degree should be 15 minutes,
> but the workers may enter every time, such as 357 or maybe 1:38.
> 
> Is there any better way to determine the next 15min step, than to take
> for example 38 % 15 = 8 and see whether the result is nearer to 0 or to
> 15? In this case (8) 8 + 8 would be 16 so i would save 45 minutes of work.

$time = 38;
$roundedTime = 15 * round($time/15);

// $roundedTime is 45

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux