Advertisement
yesamarcos

Como converter minutos em horas, minutos?

Apr 22nd, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. <?php
  2.  
  3. function converterHorasMinutos($tempo_total, $formato = '%02d:%02d') {
  4.  
  5. if ($tempo_total < 1) {
  6. return;
  7. }
  8. $horas = floor($tempo_total / 60);
  9. $minutos = ($tempo_total % 60);
  10.  
  11. return sprintf($formato, $horas, $minutos);
  12. }
  13.  
  14. $pecas = 23;
  15. $tempo_unitario = 20;
  16. $tempo_total = $pecas * $tempo_unitario;
  17. echo converterHorasMinutos($tempo_total, '%02d horas %02d minutos');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement