Okay as you can probably tell from the title of this post. I'm trying to work how to create a 24 hour remaining count down clock. I just can't get my head around how to work this out.
I've got it working with 5 minutes, but I just need a nudge in the right direction on how to turn this into hours instead of
HTML:
<body>
<input type="text" value="5">
<div>Time Remaining <span id="remainingTime">05:00</span> minutes!</div>
</body>
JavaScript/jQuery:
function Timer(duration, display)
{
var timer = duration, minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.text(minutes + ":" + seconds);
if (--timer < 0) {
timer = duration;
}
}, 1000);
}
jQuery(function ($)
{
var fiveMinutes = 60 * jQuery('#checkTime').val();
var display = $('#remainingTime');
Timer(fiveMinutes, display);
});
No plugins please.