How to convert seconds to time format?

To convert seconds to a time format in PHP, you can use the date function and specify the format you want to use. For example, to convert seconds to a time format that displays the hours, minutes, and seconds, you can use the following code:

<?php

$seconds = 12345;
$time = date("H:i:s", $seconds);
echo $time;

This will output the time in the format 03:25:45.

You can also use the gmdate function instead of date if you want to use Greenwich Mean Time (GMT) instead of the local time. For example:

<?php

$seconds = 12345;
$time = gmdate("H:i:s", $seconds);
echo $time;

This will also output the time in the format 03:25:45.

You can find more information about the date and gmdate functions in the PHP documentation:

You can also use the DateTime class to convert seconds to a time format. For example:

<?php

$seconds = 12345;
$time = new DateTime();
$time->setTimestamp($seconds);
echo $time->format('H:i:s');

This will also output the time in the format 03:25:45.

You can find more information about the DateTime class in the PHP documentation: