I want to make this JavaScript countdown timer show 01 instead of 1 and 00 when there's nothing in that part. I'm basically just trying to make it look like a digital clock, but it looks weird when theres no 0 making it squeeze in.
heres the script I found:
// JavaScript Document
CountDownTimer('03/25/2013 9:0 AM', 'countdownSpring');
CountDownTimer('06/10/2013 9:0 AM', 'countdownSummer');
CountDownTimer('11/27/2013 9:0 AM', 'countdownFall');
CountDownTimer('12/23/2013 9:0 AM', 'countdownWinter');
function CountDownTimer(dt, id)
{
var end = new Date(dt);
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance < 0) {
clearInterval(timer);
document.getElementById(id).innerHTML = 'CAMP IS HERE!';
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById(id).innerHTML = days + ':';
document.getElementById(id).innerHTML += hours + ':';
document.getElementById(id).innerHTML += minutes + ':';
document.getElementById(id).innerHTML += seconds;
}
timer = setInterval(showRemaining, 1000);
}