JavaScript: Countdown Timer
This script counts down to the date specified in new Date when placed in the body of your document.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
var date = new Date("January 1, 2100");
var now = new Date();
var diff = date.getTime() - now.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
document.write("<B>")
if (days > 1) {
document.write(days+1 + " days until the next century!<\/B>");
if (days == 26 ) {
// 4 weeks prior to the event
document.write("<BR>Only 4 weeks to go!");
}
else if (( days > 8 ) && ( days < 26 )) {
document.write("<BR>Getting close!");
}
}
else if (days == 1) {
document.write("The new century starts tomorrow!<\/B>");
document.write("<BR>On da' road.");
}
else if (days == -1) {
document.write("It's a new century!<\/B>");
}
else {
document.write("Whew, that was fun!<\/B>");
}
//-->
</SCRIPT>
|