Skip to content

Instantly share code, notes, and snippets.

@rodrigozem
Last active May 3, 2021 18:13
Show Gist options
  • Save rodrigozem/8ef74a8ae98dbeae8efb120b46f89029 to your computer and use it in GitHub Desktop.
Save rodrigozem/8ef74a8ae98dbeae8efb120b46f89029 to your computer and use it in GitHub Desktop.
Retorna os minutos da hora (PHP)
/* 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