We have 29 guests online
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

Calculate minutes to hours by MBK
User Rating: / 12
PoorBest 

This little recursive script calculates minutes to hours.
Example: 4 hours and 433 minutes equals 11 hours and 33 minutes

  1. <?php
  2. function calculate($hour, $min) {
  3.   if (($min-60) < 0) {
  4.     $total = "$hour:$min";
  5.     echo $total;
  6.   }
  7.   else {
  8.     $min -= 60;
  9.     $hour += 1;
  10.     calculate($hour, $min);
  11.   }
  12. }
  13.  
  14. calculate(4,433); //will echo 11:33
  15. ?>

 

 

Directory Stats

There are 923 listing and 46 categories in our website

Change Language