We have Moodle
plugin
where we add travel time
each employee. So far, we have calculated the duration of the trip in days
, since we added data for each employee only in this form timepickup
- 10.21.2105 timereturn
-23.10.2015.
The data here is added to the function:
$user->timepickup = gmdate("Y-m-d H:i", $timepickup);
$user->timereturn = gmdate("Y-m-d H:i", $timereturn);
And the calculation of the trip time here:
$datetime1 = strtotime($employee->timepickup);
$datetime2 = strtotime($employee->timereturn);
$interval = $datetime2 - $datetime1;
As you can see, we are adding an option to import exact time
to hours
and minutes
from timepickup
and timereturn
.
How to calculate the travel time and display it in days
and half days
(we assume that half day
are 4 hours
from the working day 8 hour
.
, 1 day(s)
timepickup
- 21.10.2105 08:00
timereturn
- 23.10.2015 12:00
0,5 day(s)
.