Created
October 4, 2013 22:05
-
-
Save kfriend/6833594 to your computer and use it in GitHub Desktop.
PHP: time_to_second() helper. Converts HH:MM:SS format to seconds. Can leave out hours or minutes.
This file contains hidden or 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 | |
function time_to_seconds($time = 0) | |
{ | |
list($secs, $mins, $hours) = array_pad(array_reverse(explode(':', $time)), 3, 0); | |
return ($hours * 3600) + ($mins * 60) + $secs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment