Q:

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

belongs to collection: PHP Classes & Objects Programs

0

Here, we will convert hours, minutes, and seconds into the number of seconds and print the result on the webpage.

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 hours, minutes, and seconds into the number of seconds is given below. The given program is compiled and executed successfully.

<?php
//PHP program to convert hours, minutes, and seconds
//into several seconds.
$hh = 1;
$mm = 48;
$ss = 50;

$seconds = $hh * 3600 + $mm * 60 + $ss;

print ("Number of seconds: " . $seconds);
?>

Output:

Number of seconds: 6530

Explanation:

In the above program, we created three variables $hh$mm, and $ss that are initialized with 1, 48, and 50 respectively. Then we calculated the number of seconds and printed the result on the console screen.

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

total answers (1)

PHP Classes & Objects Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
PHP program to implement a cascaded function call... >>
<< PHP program to convert seconds into hours, minutes...