Jump to content

someguyincali

New Members
  • Posts

    1
  • Joined

  • Last visited

someguyincali's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have this code that I'm trying to modify. When I enter a start time for 21:00 and an end time for 07:00 The existing code returns a negative number. I would like the function to assume that midnight passes if the original code returns a negative number and calculate duration. I need it to return the duration in the same format. Thank in advance for any help. protected function getDuration($fromTime, $toTime) { list($startHour, $startMin) = explode(':', $fromTime); list($endHour, $endMin) = explode(':', $toTime); $durationMinutes = (intVal($endHour) - intVal($startHour)) * 60 + (intVal($endMin) - intVal($startMin)); $hours = $durationMinutes / 60; return number_format($hours, 2); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.