Given the number of seconds left, you can use division and rounding to convert to a whole amount in a larger unit. After that the modulo operator can determine the remaining seconds. Example: PHP: $totalSeconds = 90;$minutes = floor($totalSeconds / 60); // the divisor is 60 because 60 seconds fit into 1 minute$seconds = $totalSeconds % 60;echo $minutes.":".$seconds;// output: 1:30 A similar approach for hours: PHP: $totalSeconds = 3800;$minutes = floor($totalSeconds / 60);$seconds = $totalSeconds % 60;$hours = floor($minutes / 60); // the divisor is still 60 because 60 minutes fit into 1 hour$minutes = $minutes % 60;echo $hours.":".$minutes.":".$seconds;// output: 1:3:20