I'm need a bit of php code that takes a start time and a finish time, say 7:00 and 9:30, and translates the difference to a decimal number, such as 2.5 in this case.
Any ideas?
Need help with a bit of logic..
Moderator: General Moderators
-
pistolfire99
- Forum Commoner
- Posts: 58
- Joined: Thu May 23, 2002 3:18 pm
Well, lets play around with this idea...
You take 2 time measurements and store them in two different variables. Take the difference. This will be in seconds. Divide that by (60) and you will get the value in minutes.
Now, if your time difference is 9000, when u divide it by (60), you will get 150 and if you further divide it by 60, you will get 2.5. Im not sure if this is what you were asking or did I miss the question?
You take 2 time measurements and store them in two different variables. Take the difference. This will be in seconds. Divide that by (60) and you will get the value in minutes.
Now, if your time difference is 9000, when u divide it by (60), you will get 150 and if you further divide it by 60, you will get 2.5. Im not sure if this is what you were asking or did I miss the question?
Try this, I'm not sure about strtotime though......
Code: Select all
<?php
$time1 = strtotime("03:10");
$time2= strtotime("15:20");
$time3 = $date2 - $date1;
$time3 = date("H:i",$time3);
echo $time3;
?>