0

I have an employee timesheet where durations are divided by the number of days an employee works.

E.g 25:00 over 3 days = 25:00/3=08:20

I have tried the simple divide query above, however this does not show a result. Is it possible to divide a h:m string?

Shane
  • 735
  • 3
  • 7
  • 20

1 Answers1

4

Best approach would be to convert to seconds and use date to display it.

$time ="25:00";
$days = 3;

list($hours, $minutes) = explode(":", $time);
$minutes += $hours*60;
$seconds = $minutes*60;
date_default_timezone_set ("UTC");
echo "new time: " . date("h:i", $seconds/$days);

See the result here

ThomasVdBerge
  • 6,316
  • 3
  • 39
  • 58