I am currently trying to get a countdown clock using a unix timestamp value (remaining seconds) to H:M:S format, in order to sync my client side timers.
The value that I need to change to H:M:S has already been calculated as the time remaining in the countdown.
Let
$remaining_time
be our value of remaining seconds in the countdown.
Currently, here is what I have:
$H = floor($remaining_time / 3600);
$M = floor(($remaining_time - ($H*3600)) / 60);
$S = floor($remaining_time - ($H*3600 - ($M*60)));
I believe the hours/minutes is pretty close... but the seconds seems to be off. For example, I am getting results like this
$remaining_time = 4135;
Result: Time Remaining at price formatted: H:1 M:8 S:1015
Any information is appreciated - again, I need the remaining seconds in hours, minutes, and seconds.