Ho provato a modificare il primo codice (non so se funziona):
Codice HTML:
<SCRIPT LANGUAGE="JavaScript">
<!--
function getTime() {
now = new Date();
y2k = new Date("Dec 25 2002 00:00:00");
days = (y2k - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? " second" : " seconds";
min = (minutesRound == 1) ? " minute" : " minutes, ";
hr = (hoursRound == 1) ? " hour" : " hours, ";
dy = (daysRound == 1) ? " day" : " days, "
countdown.innerHTML= "There's " + daysRound + dy + hoursRound + hr + minutesRound + min + secondsRound + sec + " before next Xmas!";
newtime = window.setTimeout("getTime();", 1000);
}
// -->
</script>
Dove vuoi che appaia il countdown metti questo:
Codice HTML:
<span id="countdown"></span>
E il body lo modifichi in questo modo:
Codice HTML:
<BODY onLoad="getTime()">