![]() |
HJB 3/16/2017 |
http://stackoverflow.com/questions/5608967/how-to-add-5-minutes-to-current-datetime-on-php-5-3 |
H
|
Hertz2P author 3/16/2017 |
http://stackoverflow.com/questions/5608967/how-to-add-5-minutes-to-current-datetime-on-php-5-3 For inspiration purposes only. Anything around the topic ROUNDING has TWO walls to hit, say, next lower and next upper value, example: you have 13 minutes, then a ROUNDING code would then downturn to 12 minutes as next 18 minutes (upper) is too far away by means of rounding logics. What you are looking is something else, say, on minute 7 the billing needs to show 12, yet any rounding formula would downturn your 7 to 6 as rounding between 6 and 12 means that 9 would be the middle axis between upper and lower rounding result to go. Not ROUNDING, but only ADDITION can solve your problem.
|
![]() |
HJB 3/17/2017 |
Try this function: function blockMinutesRound($hour, $minutes = '6', $format = "H:i") { |
H
|
Hertz2P author 3/18/2017 |
Try this function: function blockMinutesRound($hour, $minutes = '6', $format = "H:i") {
|
![]() |
HJB 3/18/2017 |
I'm pretty sure this isn't SQL code, but I'm not sure where I would put this. My original code is a simple SQL string that I wrote on the Query page.
|
Y
|
YCH 3/20/2017 |
@Hertz2P |
H
|
Hertz2P author 3/20/2017 |
@Hertz2P If you want to use SQL, you could use the 'DIV' function. This function discards from the division result any fractional part to the right of the decimal point. For your purpose use this : Time (in seconds) DIV 360 ( = 6 minutes or 0.1 hour) say 3 minutes : result --> 180 DIV 360 will return 0 then add 1 to the result . Final result = 1 ( = 1 unit of 6 minutes) say 7 minutes : result --> 420 DIV 360 will return 1 then add 1 to the result . Final result = 2 ( = 2 units of 6 minutes)
((time_to_sec(timediff(`end time`,`start time`))DIV 360)*.1)+.1 AS `total time`,
|