Kód:
<script language="JavaScript" type="text/javascript">
document.write('A hitetlen .hu megnyitásától eltelt idő:<b><div id="sarducciClock"></div></b>');
clockCountdown();
clockCountdown();
function toDateString(strTempString) { strReturnString = ""; if (strTempString < 10) { strReturnString += "0"; } return strReturnString + strTempString.toString(); } function clockCountdown() { var strEventDate = new Date("September 03, 2005 14:00:00 GMT+2"); // cl = document.clock; newDate = new Date(); intCount = Math.floor((newDate.getTime() - strEventDate.getTime())/1000); if(intCount <= 0) { document.getElementById("sarducciDisplay").style.display = "none"; document.getElementById("sarducciClock").style.display = "none"; return; }
intSeconds = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intMinutes = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intHours = toDateString(intCount % 24); intCount = Math.floor(intCount / 24); intDays = intCount;
document.getElementById("sarducciClock").innerHTML = intDays + " Nap, " + intHours + " Óra, " + intMinutes + " Perc, " + intSeconds + " Másodperc"; setTimeout("clockCountdown();", 500); } </script>
__________________________________________________________________________
Jó tanács:
Script a Greenwichi Középidőhöz igazodik. (Greenwich Mean Time - GMT ) Magyarország +1 időzónához van sorolva. Mivel nyári időszámítás szerint, még +1 órát kell hozzáadni az aktuális időhöz, ezért a kódban télen nyáron állítanod kell az időpontot. (télen GMT+1) Erről a sorról van szó: var strEventDate = new Date("August 06, 2006 14:00:00 GMT+2 ");
Két ilyen Script egy oldalon "összekad" és tehát nem működik, ezért a függvények nevét át kell írnod pl. a második Scriptben.
Pl. a második Script így nézzen ki. (a függvények más nevet adtam, hozzáírtam egy kettest.)
<script language="JavaScript" type="text/javascript">
document.write('A hitetlen .hu megnyitásától eltelt idő :<br><b><div id="winerCountdown2 "></div></b>');
winerClockCountdown2 ();
function toDateString(strTempString) { strReturnString = ""; if (strTempString < 10) { strReturnString += "0"; } return strReturnString + strTempString.toString(); } function winerClockCountdown2 () { var strEventDate = new Date("September 03, 2005 14:00:00 GMT"); // cl = document.clock; newDate = new Date(); intCount = Math.floor((strEventDate.getTime() - newDate.getTime())/1000); if(intCount <= 0) { return; }
intSeconds = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intMinutes = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intHours = toDateString(intCount % 24); intCount = Math.floor(intCount / 24); intDays = intCount;
document.getElementById("winerCountdown2 ").innerHTML = intDays + " Nap, " + intHours + " Óra, " + intMinutes + " Perc, " + intSeconds + " Másodperc"; setTimeout("winerClockCountdown2 ();", 500); }
</script>
Figyelem! A hónapok nevét csak angolul fogadja el: January February March April May June July August September October November December