Last active
May 3, 2021 18:13
-
-
Save rodrigozem/8ef74a8ae98dbeae8efb120b46f89029 to your computer and use it in GitHub Desktop.
Retorna os minutos da hora (PHP)
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
/* Return total minutes */ | |
function get_minutes($hr) | |
{ | |
$time = explode(":",$hr); | |
$t1 = intval($time[0]) * 60; | |
$t2 = intval($time[1]); | |
if ( strpos($t1,'-') !== false ) | |
return $t1 - $t2; | |
else | |
return $t1 + $t2; | |
} | |
Ex: get_minutes("150:31"); | |
/* Returns 9031 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment