View Full Version : countdown - countup script???

12-27-2003, 11:13 AM

I really have a big problem and hope anyone here can help me. I would like to put the 'countup' AND the 'countdown' scprit on my homepage, but they don't work together.
I read the instruction how to change the code to make them work together, but for some reason they still don't. I don't know why, maybe I'm doing something wrong.

Could someone please please help me and write me how to change it, or even change it for me and just paste me the two changed scripts?

I would really appreciate it so much, because I had such a hard time changing everything and it still didn't work.

Please, please help me!

Thanks in advance!

12-27-2003, 03:41 PM
You really only need one function:

function countIt(dateStr, evtStr) {

var now = new Date(), then = new Date(dateStr);
var diff = Math.floor((now.getTime() - then.getTime()) / (1000*60*60*24));

return Math.abs(diff) + ' days ' + ((diff < 0) ? ' \'till ' : ' since ') + evtStr + '.<br />';


Then, to write it to the page, you could do something like this:

document.write(countIt('December 25, 2003', 'Christmas 2003'));
document.write(countIt('January 1, 2004', 'New Year 2004'));

Hope that helps!

Happy coding! :)

12-27-2003, 09:37 PM
Thank you soooooooooo much, I'll try! :)