A Countdown Clock in JavaScript


Note that this clock is incorrect. Negative numbers resulted from some minute and second calculations thus absolute values were taken. Dumb ! Yes. I just did not want to have to think too hard at 1am in the morning.

now = new Date ();
y2k = new Date ("Jan 01 2000 00:00:00");
seconds = Math.round ((y2k - now) / 100);
minutes = Math.round (seconds / 60);
seconds = Math.abs (seconds - (minutes * 60));
hours = Math.round (minutes / 24);
minutes = Math.abs (minutes - (hours * 24));
document.write (Math.round(hours) + "h : " + Math.round(minutes) + "m : " + Math.round(seconds) + "s");