Countdown Timer

UPDATE: 14 April 2010

Added template support... now you can define what the timer says!
The time components are also padded with zero now when less than 10.

Templates take the following placeholders:
Example: '{days} days<br />{hours}:{minutes}:{seconds}'

UPDATE: 30 January 2008

Fixed end-of-month bug; thanks to Jarin Blackham for catching it for me.

How Does it Work?

This is a Countdown Timer that can be put anywhere in any web page by simply passing the ElementNode object you need the timer to attach itself to.

This timer is cool because it is fully self-contained, will clear its update interval and remove itself from the document completely the second after its time expires. (Watch the tester)

* If you plan to use multiple timers in your page, make sure to send in unique iCountdownNodeIds.

CSS your timer by setting the following rules: (according to the iCountdownNodeId you send in)
countdownDiv is used if you don't send one in.


If you used myTimer as the iCoundownNodeId:

In this particular demonstration, I also use my Time Converter JavaScript code to make generating my timer date's easier.

To use: ** I plan on adding better date format support later... especially YYYY-DD-MM HH:II:SS **
	<script type="text/javascript" src="countdown.js"></script>
	<script type="text/javascript">
		function AfterLoad()
			CreateCountdown("Time until July 4, 2121", "07-04-2121", document.body, 'myTimer');
		window.onload = AfterLoad;

AddCountdownTester( iNumSeconds );