function liczCzas()
{
now = new Date();
rok = now.getFullYear();
miesiac = now.getMonth();
dzien = now.getDate();
to = new Date(rok,miesiac,dzien,12,0,0);
ile = to.getTime() - now.getTime();
godzin = Math.floor(ile / (1000 * 60 * 60));
minut = Math.floor( ile / (1000 * 60)-godzin*60);
sekund = Math.floor(ile / 1000 - godzin*60*60 - minut*60);
if (godzin < 0)
{
to = new Date(rok,miesiac,dzien+1,12,0,0);
ile = to.getTime() - now.getTime();
godzin = Math.floor(ile / (1000 * 60 * 60));
minut = Math.floor(ile / (1000 * 60)-godzin*60);
sekund = Math.floor(ile / 1000 - godzin*60*60 - minut*60);
}
document.getElementById("time").innerHTML = "Pozostalo: "+godzin+"
... godzin, "+minut+" minut, "+sekund+" sekund";
}
var animeInt;
clearInterval(animeInt);
animeInt = setInterval("liczCzas()", 1000);
W body teraz trzeba jeszcze dodać:
<div id="time"></div>
Walnij cos takiego jak masz np. codziennie losowanie o ktores tam to powinno dzialacCode:function liczCzas() { now = new Date(); rok = now.getFullYear(); miesiac = now.getMonth(); dzien = now.getDate(); to = new Date(rok,miesiac,dzien,12,0,0); ile = to.getTime() - now.getTime(); godzin = Math.floor(ile / (1000 * 60 * 60)); minut = Math.floor( ile / (1000 * 60)-godzin*60); sekund = Math.floor(ile / 1000 - godzin*60*60 - minut*60); if (godzin < 0) { to = new Date(rok,miesiac,dzien+1,12,0,0); ile = to.getTime() - now.getTime(); godzin = Math.floor(ile / (1000 * 60 * 60)); minut = Math.floor(ile / (1000 * 60)-godzin*60); sekund = Math.floor(ile / 1000 - godzin*60*60 - minut*60); } document.getElementById("time").innerHTML = "Pozostalo: "+godzin+" ... godzin, "+minut+" minut, "+sekund+" sekund"; } var animeInt; clearInterval(animeInt); animeInt = setInterval("liczCzas()", 1000); W body teraz trzeba jeszcze dodać: <div id="time"></div>