Suppose I have the number “13.57916667” in a variable $hours. This is a calculated hours combining minutes and seconds to hours.
I want the decimals to round up. For example, I want $hours to become 13.6. I can’t seem to find any solution anywhere, even on stackoverflow. Thanks in advance!
Well, this little snippet should do it:
If you’re looking for a
ceil()with precision:For a fixed precision of 1 decimal, that would become: