Skip to content

Instantly share code, notes, and snippets.

@p4ulypops
Created November 30, 2014 18:30
Show Gist options
  • Save p4ulypops/96544a9feb16be792bcd to your computer and use it in GitHub Desktop.
Save p4ulypops/96544a9feb16be792bcd to your computer and use it in GitHub Desktop.
<?php
// IF you want it to include the days, follow the logic.
$time = "1:66";
$timeArray = explode($time, ":");
if (count($timeArray) == 3) { // there is something like "5:12:23";
$seconds = ($timeArray[0] * 60 * 60) + ($timeArray[1] * 60) + $timeArray[2];
} elseif(count($timeArray) == 2) { // there is something like "15:60";
$seconds = ($timeArray[0] * 60) + $timeArray[1];
} else { // There is no ':" - or there is more than 3
$seconds = $time;
}
$finalTime = gmdate("H:i:s", $seconds);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment