var countdownfunc = function(elem, ende, endstring) { if(typeof endstring == 'undefined'){ endstring = '<font color="#01DF01">Startseite bereit</font>'; } var output = endstring; var timeDiff = (parseInt(ende)) - (parseInt(new Date().getTime() / 1000)); if(timeDiff > 0){ output = ''; if(timeDiff > 3600){ output += parseInt(timeDiff/3600) + 'h '; timeDiff = timeDiff%3600; //Modulo, teile durch eine stunde und speichere den rest } if(timeDiff > 60){ output += parseInt(timeDiff/60) + 'm '; timeDiff = timeDiff%60;//... und merk dir den rest } output += timeDiff + 's'; setTimeout(function() {countdownfunc(elem, ende, endstring);},1000); } elem.innerHTML = output; };