Round minute down to nearest quarter hour
I need to round times down to the nearest quarter hour in PHP. The times are being pulled from a MySQL database from a datetime column and formatted like 2010-03-18 10:50:00
.
I need to round times down to the nearest quarter hour in PHP. The times are being pulled from a MySQL database from a datetime column and formatted like 2010-03-18 10:50:00
.
So, I need to create the following functions but my head can’t think of any possibility in PHP without complicated math.
I need to mimic the exact functionality of the ceil(), floor() and round() functions on bcmath numbers, I’ve already found a very similar question but unfortunately the answer provided isn’t good enough for me since it lacks support for negative numbers and the precision argument for the round() function is missing.