#Christmas Countdowns
we're going to look at making a count down timer that you can use with the littlebits or put on a website
Start a new JSFiddle
Add in jQuery by clicking the little cog in the JavaScript square
Right click anywhere on your screen - you should be able to see a thing called "inspect" or "inspect element" - this will open up a new bit on your browser. Here you should be able to find a tab called console. This is what we're going to use to make sure our numbers are correct!
Next we need to get two dates and log them to our shiney new console:
var today = new Date().getTime();
var christmas = new Date("12/25/2015").getTime();
console.log(today);
console.log(christmas);
Now we can calculate how many seconds there are between today and christmas!
var seconds = (christmas.getTime() - today.getTime())/1000;
console.log(seconds);
Now you know how many seconds until Santa comes!
Now for a bit of maths! How many seconds are there in a minute? How many minutes are there in an hour? how many hours are there in a day?
var days = Math.floor(((seconds / 60)/60)/24);
Now we've calculated how many days left, we need to take that number of seconds away from our total seconds!
seconds = seconds - (((days * 60)*60)*24);
Have a go at calcualting how many hours and minutes there are remaining until christmas similar to how we calculated the days left!
If you get super stuck you can take a look at my JSFiddle here: https://jsfiddle.net/xzcz1goo/
Put these numbers in somewhere prettier - make your own website!