Better code for doing a date-based countdown in Javascript. The top results on Google appear to have been written in 1990 and are unnecessarily cumbersome-- here's a version I wrote for a quick Christmas "countdown" webpage.

One major advantage to my version is that it compensates for the date in a given timezone, so that it counts down to the same exact second regardless of time zone (assuming that everyone's computer time is accurate) instead of "rolling" across time zones. This is done by taking advantage of the way numerical timestamps are stored (always in GMT) and the .toUTCString commands. For an even more accurate rollout, I used inline php code to populate the timestamp number and also perform some logic when the server thinks the time has been reached, so that users can't simply change their computer's clock to see the result (which in this case is just reloading, since my PHP should have replaced the server-side HTML by that point.)

If you'd like to see the inline PHP that handles the official rollout, leave a comment!

https://gist.github.com/zyphlar/9161989