count down timer

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

count down timer

Post 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.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: count down timer

Post by greyhoundcode »

So what is your general approach going to be and what elements are you unsure of?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: count down timer

Post by pickle »

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.
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: count down timer

Post 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
Post Reply