I have the INTEGER(255) variable $duration stored with a value taken from the user. I need to round this UP to the nearest 15. I have searched all over but haven’t been able to find a solution. How may I go about doing this? For example: 10 becomes 15 16 becomes 30 130 becomes 135 Also, how can I add
Tag: rounding
How to round numbers to the closest .45 or .95?
In PHP I want to round numbers based on the value provided. If the value is more than 30, I want to round numbers to the closest 4.95 or 9.95 If the value is between 10 and 30 I want to round numbers …
Is it possible to use *= operator together with round() function
I often need to use fractional modificators for my variables. Like this: Yet I need the oputput to be rounded, so I need to use: Is is no big deal, but every single time I can not use the *= operator, and I need to write round(). Is there a shrotcut for this? Answer As $var *= 1.5; is a
What is the Difference between Floor and Round
CODE RESULTS $a = floor(3.5); //3 $b = round(3.5, 0, PHP_ROUND_HALF_DOWN); //3 var_dump($a); //float(3) var_dump($b); …
Round datetime to last hour
I tried to look for this but I could not find good example of this what im trying to do. I got datetime values in MySQL database that has to be rounded down when that value is on use. Example, all …
How can I make sure a float will always be rounded up with PHP?
I want to make sure a float in PHP is rounded up if any decimal is present, without worrying about mathematical rounding rules. This function would work as follows: 1.1 to 2 1.2 to 2 1.9 to 2 2.3 to …
PHP Undefined Constant PHP_ROUND_HALF_DOWN
I have some PHP code in a project I’m working on that uses PHP’s round function. On my localhost, I don’t include any quotes around my mode argument, stating it as just PHP_ROUND_HALF_DOWN. However, when pushing to my server I get the error message: Now, when I add the single quotes to the mode argument, the first error goes away,