// taken from http://scripts.franciscocharrua.com/countdown-clock.php // modified specifically for Peter's Date Countdown: http://www.theblog.ca/?p=41 function countdown_clock(year, month, day, hour, minute, i, timediff, javaend, textend, textevent, sleeps) { html_code = ''; document.write(html_code); countdown(year, month, day, hour, minute, i, timediff, javaend, textend, textevent, sleeps); } function countdown(year, month, day, hour, minute, i, timediff, javaend, textend, textevent, sleeps) { Today = new Date(); pdc_servergmt = 2 pdc_gmt = pdc_servergmt + Today.getTimezoneOffset()/60; Todays_Hour = Today.getHours() + pdc_gmt + timediff; //Convert both today's date and the target date into milliseconds. Todays_Date = (new Date(Today.getFullYear(), Today.getMonth(), Today.getDate(), Todays_Hour, Today.getMinutes(), Today.getSeconds())).getTime(); Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime(); // Find their difference, and convert that into seconds. Time_Left = Math.round((Target_Date - Todays_Date) / 1000); Unmod_Time = Time_Left if(Time_Left > 0) { days = Math.floor(Time_Left / (60 * 60 * 24)); Time_Left %= (60 * 60 * 24); hours = Math.floor(Time_Left / (60 * 60)); Time_Left %= (60 * 60); minutes = Math.floor(Time_Left / 60); Time_Left %= 60; seconds = Time_Left; } else if(Time_Left < 0) { if (javaend == 2) { days = Math.ceil(Time_Left / (60 * 60 * 24)); Time_Left %= (60 * 60 * 24); hours = Math.ceil(Time_Left / (60 * 60)); Time_Left %= (60 * 60); minutes = Math.ceil(Time_Left / 60); Time_Left %= 60; seconds = Time_Left; } else { days = 0; hours = 0; minutes = 0; seconds = 0; } } dps = 's'; //ps is short for plural suffix. if(Math.abs(days) == 1) dps =''; pdc_div = document.getElementById('pdc_item' + i); if (javaend == 0 && Unmod_Time < 0) { pdc_div.innerHTML = textend; } else { pdc_div.innerHTML = '' + textevent + '
'; pdc_div.innerHTML += 'Noch ' + days + ' Tage
'; pdc_div.innerHTML += hours + 'H ' + minutes + 'M ' + seconds + 'S'; } // Recursive call, keeps the clock ticking textend = textend.replace(/\'/g,'\\\''); textevent = textevent.replace(/\'/g,'\\\''); setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + i + "," + timediff + ',' + javaend + ',\'' + textend + '\',\'' + textevent + '\',\'' + sleeps + '\');', 1000); }