According to the documentation of mktime
, for minute
:
The number of the minute relative to the start of the hour. Negative values reference the minute in the previous hour. Values
greater than 59 reference the appropriate minute in the following
hour(s).
And for second
:
The number of seconds relative to the start of the minute. Negative values reference the second in the previous minute. Values
greater than 59 reference the appropriate second in the following
minute(s).
When you call mktime
you are passing a value of 0 for both hours and minutes; with 3605 seconds you are basically "spinning" the seconds
hand on the clock 3600/60 times, and then you add those 5 seconds.
So you will have to first manually calculate the correct values for minutes and possibly hours that your given amount of seconds amounts to.
For that, you will need to use mod
and intval
of the division.
In a very educational format you'd have something like:
function convert($iSeconds) {
$seconds = $iSeconds % 60;
$minutes = intval($iSeconds/60);
$hours = intval($minutes/60);
$minutes = $minutes % 60;
return date('H:i:s', mktime($hours, $minutes, $seconds));
}
https://eval.in/508531
Indeed, this doesn't directly solve the OP, as the number of minutes can be of arbitrary size. As noted, mktime
cannot be used to achieve that, as it will always format a "proper" time value, where minutes and seconds are a number between 0-59.