JavaScript countdown, formatting seconds to HH:MM:SS
<p>I have a countdown timer that takes 'seconds' and formats it into HH:MM:SS format.  The problem is the second shows 60.</p>

<p>Here's the code I have, this is part of a much larger class.   Any suggestions on the best way format so that it doesn't use '60' as a second.</p>

<p>Thank you!</p>

<pre><code>formatSeconds: function (seconds) {

    secondsRemaining = seconds;
    hoursRemaining = Math.floor(secondsRemaining / (60 * 60));
    minutesRemaining = secondsRemaining % (60 * 60);

    hourMinutesRemaining = Math.floor(minutesRemaining / 60);
    minuteSecondsRemaining = minutesRemaining % 60;
    hourSecondsRemaining = Math.ceil(minuteSecondsRemaining);

    fHrs = this.formatNumber(hoursRemaining);
    fMins = this.formatNumber(hourMinutesRemaining);
    fSecs = this.formatNumber(hourSecondsRemaining);

    return fHrs + ':' + fMins + ':' + fSecs;
},

formatNumber: function (number) {
    var s = String(number);
    if (s.length == 1) {
        s = '0' + s;
    }
    return s;
}
</code></pre>
