Event Countdown Code

Very often, a club or organization will have a big event (a tournament, a show, a lecture, you name it) that it will want to feature prominently on its website. In fact, as the event gets closer, the club might want to feature it more prominently. Of course, once the event is past, it should fade into the background.

You can use JavaScript to make these customizations, based on how far away the event is. You can look at the date dependent code example to see how to do the customizations. This page describes and demonstrates the JavaScript calculations necessary to find out how far away the event is, based on the date of the event and the current date.

Customization Example

For this demonstration, we will assume that you are interested in how many days remain until the polls open at 7am on the day of the 2016 election, namely November 8th, 2016.

What will we do with this information? The page will tell you how many days remain, and it will adjust the font size based on how far away the election is. (This will stand in for whatever adjustments you might make for your own event.)

Customizations in Action

Just so you know, election day is

insert days here

How It's done

There are several ways this could be done. Here's how we did the computation:

Use view source on this page to see exactly how we did it.