Created
July 11, 2021 14:53
-
-
Save camilamoreiradev/c65643c6c7b9607bc3afb3d3fffcde10 to your computer and use it in GitHub Desktop.
Function for converting hours into seconds.
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
function convertHourForSeconds($hour) { | |
$partHour = explode(':', $hour); | |
$seconds = ($partHour[0] * (3600)) + ($partHour[1] * 60) + $partHour[2]; | |
return $seconds; | |
} | |
$hour = '04:09:53'; | |
$seconds = convertHourForSeconds($hour); | |
/* | |
The return is 14993 seconds. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment