What I want is to divide a string in timeformat, lets say 27:30. How can I do that? Eventually I can use SQL for it, because the string comes from the database.
I have tried this in MySQL by the way:
TIMEDIFF(TIMEDIFF(u.hour_end, u.hour_begin),TIME(l.u_contract) / 5) AS contract
And this does not work.
What exactly do you want ? How is the value stored in the database and how do you want to split it ?
No I want to divide it. Simple dividing a number that is in timeformat, e.g. 37:40 / 5. For example.
Note that is 37 hours and 40 minutes.
list($hrs, $mins) = explode(":", $time); $mins += $hrs * 60; $endresult = $mins/5; echo $endresult;
You make a little mistake I think, the code you are showing must be, I think:
list($hrs, $mins) = explode(":", $time); $mins += $hrs / 60; $endresult = $hrs/5; echo $endresult;
This code is not what I actually intended, because when you take for exampble the time 37:00, you get with the code above as $endresult: 7.4. And the $result must be 7:24.
<?php $time = "37:00"; list($hrs, $mins) = explode(":", $time); $mins += $hrs * 60; $endresult = $mins/5; echo date("H:i",mktime(0,$endresult,0,0,0,0)); ?>
You make a little mistake I think, the code you are showing must be, I
Actually it does exactly what I was thinking:
(30 + (27 * 60)) / 5 = 330 minutes
Thanks Nav33n and R0bb0b for the kindfull answer.
You where right, and it is working now.