Q:

PHP program to convert seconds into hours, minutes, and seconds

0

Here, we will convert the number of seconds into hours, minutes, and seconds.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to convert seconds into hours, minutes, and seconds is given below. The given program is compiled and executed successfully.

<?php
//PHP program to convert seconds into
//hours, minutes, and seconds
$seconds = 6530;

$secs = $seconds % 60;
$hrs = $seconds / 60;
$mins = $hrs % 60;

$hrs = $hrs / 60;

print ("HH:MM:SS-> " . (int)$hrs . ":" . (int)$mins . ":" . (int)$secs);

?>

Output:

HH:MM:SS-> 1:48:50

Explanation:

In the above program, we created a variable $seconds, which is initialized with 6530 seconds. Then we converted the seconds into hours, minutes, and seconds respectively.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now