function zeroPad(num,count){ var numZeropad = num + ''; while(numZeropad.length < count) { numZeropad = "0" + numZeropad; } return numZeropad; } function countdown_clock(year, month, day, hour, minute, format) { Today = new Date(); Todays_Year = Today.getFullYear() - 2000; Todays_Month = Today.getMonth(); //Computes the time difference between the client computer and the server. Server_Date = (new Date(12, 1, 28, 01, 43, 17)).getTime(); Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime(); countdown(year, month, day, hour, minute, (Todays_Date - Server_Date), format); } function countdown(year, month, day, hour, minute, time_difference, format) { Today = new Date(); Todays_Year = Today.getFullYear() - 2000; Todays_Month = Today.getMonth(); Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime(); Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime(); Time_Left = Math.round((Target_Date - Todays_Date + time_difference) / 1000); Weekend = 1; if(Time_Left < 0) { Time_Left = 0; document.getElementById('countdown').innerHTML = 'så sender vi din ordre imorgen!'; document.getElementById('countdown_line1').innerHTML = 'Bestil idag'; document.getElementById('countdown_line2').innerHTML = ''; } else if(Weekend == 1) { document.getElementById('countdown').innerHTML = 'så sender vi din ordre på Mandag!'; document.getElementById('countdown_line1').innerHTML = 'Bestil idag'; document.getElementById('countdown_line2').innerHTML = ''; } else { days = Math.floor(Time_Left / (60 * 60 * 24)); Time_Left %= (60 * 60 * 24); hours = zeroPad(Math.floor(Time_Left / (60 * 60)),1); Time_Left %= (60 * 60); minutes = zeroPad(Math.floor(Time_Left / 60),1); Time_Left %= 60; seconds = zeroPad(Time_Left,1); document.getElementById('countdown').innerHTML = hours + ' time(r) '; document.getElementById('countdown').innerHTML += minutes + ' min '; document.getElementById('countdown').innerHTML += seconds + ' sek'; document.getElementById('countdown_line1').innerHTML = 'Bestil inden: '; document.getElementById('countdown_line2').innerHTML = 'så sender vi din ordre idag!'; setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + time_difference + ', ' + format + ');', 1000); } }countdown_clock(12, 1, 28, 16, 00, 1)