Skip to content

Instantly share code, notes, and snippets.

@camilamoreiradev
Created July 11, 2021 14:53
Show Gist options
  • Save camilamoreiradev/c65643c6c7b9607bc3afb3d3fffcde10 to your computer and use it in GitHub Desktop.
Save camilamoreiradev/c65643c6c7b9607bc3afb3d3fffcde10 to your computer and use it in GitHub Desktop.
Function for converting hours into seconds.
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