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.
count down timer
Moderator: General Moderators
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: count down timer
So what is your general approach going to be and what elements are you unsure of?
Re: count down timer
Yah - what have you tried yourself?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: count down timer
well i found some code however its not exactly like i want but either i could use it or figure how to modifiy it.
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
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);
}