Christmas Countdown Script
Now that there are only
Here's the effect:
And here's the code:
<script type="text/javascript">
<!-- Begin
var date = new Date("December 25, 2007");
var description = "Christmas";
var now = new Date();
var diff = date.getTime() - now.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
if (days > 1) {
document.write(days+1 + " days until " + description);
}
else if (days == 1) {
document.write("Only two days until " + description);
}
else if (days == 0) {
document.write("Tomorrow is " + description);
}
else {
document.write("It's" + description + "!");
}
// End -->
</script>
As usual, select all the code and paste into the <body> section of your page where you need it.
You can alter a few parameters in this script to count down to any date you choose. The appropriate points are:
var date = Substitute whatever date you require where I've got ("December 25, 2007").
Keep the format the same, though var description= insert whatever text you require here.
You'll note that I've actually used the effect in the standfirst to the page - it's worthwhile right clicking and reading the source of the page to see how that works.
This is a fairly simple script, which you can bend to your own use relatively easily. Have fun with it (but, as ever, don't overdo it)


