Page 1 of 1
count down timer
Posted: Thu Jun 02, 2011 4:21 pm
by nite4000
hey everyone. this is my first post with a JS task
I need a count down timer. I need to have it allow me to set a time and only like say set it for 11am then when it reaches 11am it would start over to count down to the next day at 11am.
if anyone can help me out thanks.
Re: count down timer
Posted: Thu Jun 02, 2011 5:02 pm
by greyhoundcode
So what is your general approach going to be and what elements are you unsure of?
Re: count down timer
Posted: Thu Jun 02, 2011 5:06 pm
by pickle
Yah - what have you tried yourself?
Re: count down timer
Posted: Thu Jun 02, 2011 5:15 pm
by nite4000
well i found some code however its not exactly like i want but either i could use it or figure how to modifiy it.
Code: Select all
var now = new Date();
var event = new Date("18:20:00");
var seconds = (event - now) / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
ID=window.setTimeout("update();", 1000);
function update() {
now = new Date();
seconds = (event - now) / 1000;
seconds = Math.round(seconds);
minutes = seconds / 60;
minutes = Math.round(minutes);
hours = minutes / 60;
hours = Math.round(hours);
days = hours / 24;
days = Math.round(days);
document.form1.days.value = days;
document.form1.hours.value = hours;
document.form1.minutes.value = minutes;
document.form1.seconds.value = seconds;
ID=window.setTimeout("update();",1000);
}
i just tried it and it gave me 17hrs til 11am tomorrow but thats now right i would need it to really run on server time