Problem Description
We have `Moodle` `plugin`, where we add the `travel time` of each employee.
Until now, we calculated the duration of the travel time in `days`, as we added the data for every employee only in such form `timepickup`- 21.10.2105 `timereturn`-23.10.2015.
The data was being added in the function here:
$user->timepickup = gmdate("Y-m-d H:i", $timepickup);
$user->timereturn = gmdate("Y-m-d H:i", $timereturn);
And the calculating of the travel time here:
$datetime1 = strtotime($employee->timepickup);
$datetime2 = strtotime($employee->timereturn);
$interval = $datetime2 - $datetime1;
As you can see, we add the option to import the `exact time` in `hours` and `minutes` of the `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 `8 hour` working day.
So instead of travel time `1 day(s)` for adding `timepickup`- `21.10.2105 08:00` `timereturn`-`23.10.2015 12:00`, we will have displayed `0,5 day(s)`.
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?