Forum Moderators: mack

Message Too Old, No Replies

Count Down Clock

i want to use java script to make counting donw clock

         

Penguinsnob

10:07 am on May 22, 2003 (gmt 0)

10+ Year Member



my web site is decicated to this event that is going to take place on octorber 11th 2003, and i want to make a clock that counds down time remain in form like,

141 days 2 hours and 22 seconds till XYZ event

I saw some java script that canculate time difference but I want a clock that counds down real time, maybe every 15 seconds or so.

Mardi_Gras

11:48 am on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know Hotscripts has some countdown scripts. I'm sure the other script sites do as well. Unless you're committed to writing your own, I would start there.

dmorison

12:12 pm on May 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One of my sites has a count down timer.

The server calculates "seconds" at page generation time, so you may have to add some code to calculate the number of seconds remaining if you're not going to do it server side...

Here's the code - modified off the top of my head to include days, but it should be ok....

<script type='text/javascipr'>

var seconds = 42772;

function countdown()
{
var t,d,h,m,s;

t = seconds;

d = parseInt(t / 86400);

t = t - (d * 86400);

h = parseInt(t / 3600);

t = t - (h * 3600);

m = parseInt(t / 60);

t = t - (m * 60);

s = parseInt(t);

document.getElementById("d").innerHTML = d;

document.getElementById("h").innerHTML = h;

document.getElementById("m").innerHTML = m;

document.getElementById("s").innerHTML = s;

seconds = seconds - 1;

if (seconds > -1) window.setTimeout("countdown()",1000);
}

countdown();

</script>

<div id='d'></div> DAYS
<div id='h'></div> HOURS
<div id='m'></div> MINUTES
<div id='s'></div> SECONDS

Should give you the mechanics. Good luck!