<?php
$entrada = array( 'h'=>23, 'm'=>15 ); $saida = array( 'h'=>11, 'm'=>30 );
print_r( intervalo
( $entrada, $saida ) );
function intervalo( $entrada, $saida ) {
$minutos = ( $saida['h'] - $entrada['h'] ) * 60 + $saida['m'] - $entrada['m'];
if( $minutos < 0 ) $minutos += 24 * 60;
return array( 'h'=>(int
)( $minutos / 60), 'm'=>( $minutos % 60 ) ); }
PD9waHAKICAgICRlbnRyYWRhID0gYXJyYXkoICdoJz0+MjMsICdtJz0+MTUgKTsKICAgICRzYWlkYSAgID0gYXJyYXkoICdoJz0+MTEsICdtJz0+MzAgKTsKCiAgICBwcmludF9yKCBpbnRlcnZhbG8oICRlbnRyYWRhLCAkc2FpZGEgKSApOwoKICAgIGZ1bmN0aW9uIGludGVydmFsbyggJGVudHJhZGEsICRzYWlkYSApIHsKICAgICAgICRtaW51dG9zID0gKCAkc2FpZGFbJ2gnXSAtICRlbnRyYWRhWydoJ10gKSAqIDYwICsgJHNhaWRhWydtJ10gLSAkZW50cmFkYVsnbSddOwogICAgICAgaWYoICRtaW51dG9zIDwgMCApICRtaW51dG9zICs9IDI0ICogNjA7CiAgICAgICByZXR1cm4gYXJyYXkoICdoJz0+KGludCkoICRtaW51dG9zIC8gNjApLCAnbSc9PiggJG1pbnV0b3MgJSA2MCApICk7CiAgICB9Cg==