0

Hello all,

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.

Thanks before!

3
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by kvdd
0

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.

Anyone?

0

What exactly do you want ? How is the value stored in the database and how do you want to split it ?

0

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.

0

Like this?

list($hrs, $mins) = explode(":", $time);
$mins += $hrs * 60;
$endresult = $mins/5;
echo $endresult;
0

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.

2
<?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));
?>

Now ?

Votes + Comments
He gives me a complete solution, thanks nav33n!
Thankyou
1

You make a little mistake I think, the code you are showing must be, I

Actually it does exactly what I was thinking:
27:30
(30 + (27 * 60)) / 5 = 330 minutes

Votes + Comments
He helped me kindfull
0

Thanks Nav33n and R0bb0b for the kindfull answer.
You where right, and it is working now.

Again thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.