Created
November 30, 2014 18:30
-
-
Save p4ulypops/96544a9feb16be792bcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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