Countdown timer

By Massimo vMassimo v

Description

This is a simple countdown timer. I Slightly edited it to fit for the holidays.

Code

<script type="text/javascript">
today = new Date();
BigDay = new Date("December 25, 2014"); // Change date to countdown to
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
document.write("Er zijn nog maar : <BR> <H4>" + daysLeft + " dagen " + hrsLeft +" Uren " + minsLeft + "  minuten over</H4> Tot het Kerstmis is! <P>"); // you can change the words, Don't change the methods 
// origineel afkomstig van moonfruit.com Aangepast door Massimo methode aangepast en vertaald 
</script>

Blank version ( for easy editing)
Dont forget the html tag when inserting

<script type="text/javascript">
today = new Date();
BigDay = new Date("Month dayofmonth, year"); // Change date to the day you would like to countdown to
msPerDay = 24 * 60 * 60 * 1000 ;  // Vbs
timeLeft = (BigDay.getTime() - today.getTime());// Vbs
e_daysLeft = timeLeft / msPerDay;// Vbs
daysLeft = Math.floor(e_daysLeft);// Vbs
e_hrsLeft = (e_daysLeft - daysLeft)*24;// Vbs
hrsLeft = Math.floor(e_hrsLeft);// Vbs
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);// Vbs
document.write("there are only ... the days left will come after this " + daysLeft + " Days  " + hrsLeft +" Hours " + minsLeft + "  Minutes</H4> Until it is ... your reason of count down like my birthday or ... <P>"); 
// I started this from something I got from moonfruit.com  Credits for them. 
</script>

That's how it would look like


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Massimo v


Rate this solution

If you think this solution is useful — rate it up!

rating: +6+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License