fork download
  1. <?php
  2.  
  3. $data1 = '2021-02-23 00:00:00';
  4. $data2 = date('Y-m-d H:i:s', strtotime("-3 hours", strtotime("now")));
  5.  
  6. $unix_data1 = strtotime($data1);
  7. $unix_data2 = strtotime($data2);
  8.  
  9. $nHoras = ($unix_data2 - $unix_data1) / (60 * 60);
  10. $nMinutos = (($unix_data2 - $unix_data1) % (60 * 60)) / 60;
  11.  
  12. // printf('%02d:%02d', $nHoras, $nMinutos);
  13.  
  14. $resultado = sprintf('%02d:%02d', $nHoras, $nMinutos);
  15. echo "Hora: {$resultado}"
  16.  
  17. ?>
Success #stdin #stdout 0.02s 24612KB
stdin
Standard input is empty
stdout
Hora: 06:17