<script type="text/javascript">
<!--
// Countdown Script by Virtual_Max
// http://www.geocities.com/siliconvalley/lakes/8620
// please keep this comment unchanged if you use it
// Modified: Osmo Saarikumpu 2002-06-14
// aseta 0-hetki seuraavaan:
var eventdate = new Date("December 25, 2009 00:00:00 GMT +0200");
function toSt(n)
{s=""
if(n<10) s+="0"
return s+n.toString();
}
function countdown()
{cl=document.clock;
d=new Date();
count=Math.floor((eventdate.getTime()-d.getTime())/1000);
if(count<=0)
{cl.days.value ="0000";
cl.hours.value="00";
cl.mins.value="00";
cl.secs.value="00";
return;
}
cl.secs.value=toSt(count%60);
count=Math.floor(count/60);
cl.mins.value=toSt(count%60);
count=Math.floor(count/60);
cl.hours.value=toSt(count%24);
count=Math.floor(count/24);
cl.days.value=count;
setTimeout("countdown()",500);
}
// -->
</script>
<body onload="countdown()">
<form name="clock" action="javascript:void('0');">
<table border="0" align="center">
<tr>
<td colspan="2">
Jouluun 2009 on enää:
</td>
</tr>
<tr>
<td >
<input name="days" size="4" />
</td>
<td >
päivää
</td>
</tr>
<tr>
<td >
<input name="hours" size="4" />
</td>
<td >
tuntia
</td>
</tr>
<tr>
<td >
<input name="mins" size="4" />
</td>
<td >
minuuttia ja
</td>
</tr>
<tr>
<td >
<input name="secs" size="4" />
</td>
<td >
sekunttia jäljellä...
</td>
</tr>
</table>
</form>
<script type="text/javascript">
document.write("\(Määräajaksi on asetettu "+eventdate.toGMTString()+".\)");
</script>
Aiheesta löytyy myös yksinkertaisempi versio.