fork(2) download
  1. <?php
  2. $entrada = array( 'h'=>23, 'm'=>15 );
  3. $saida = array( 'h'=>11, 'm'=>30 );
  4.  
  5. print_r( intervalo( $entrada, $saida ) );
  6.  
  7. function intervalo( $entrada, $saida ) {
  8. $minutos = ( $saida['h'] - $entrada['h'] ) * 60 + $saida['m'] - $entrada['m'];
  9. if( $minutos < 0 ) $minutos += 24 * 60;
  10. return array( 'h'=>(int)( $minutos / 60), 'm'=>( $minutos % 60 ) );
  11. }
  12.  
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [h] => 12
    [m] => 15
)