Not long ago I Blogged about a Coldfusion method for counting down to a specific date. Well, if you don't have access to a coldfusion server for your site, it's pretty easy to add the same function with Javascript.
I found this script at: JavaScriptKit It's really simple to modify.
/* Count down until any date script- By JavaScript Kit (www.javascriptkit.com) Over 200+ free scripts here! */
//change the text below to reflect your own,
var before="My Birthday!" var current="Today is My Birthday, Dont forget to visit my wishlist" var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
document.write(current)
else if (difference>0)
document.write("Only "+difference+" days until "+before)
}
//enter the count down date using the format year/month/day
countdown(2007,2,25)
Just modify the “var before ” and “var current” text to your own text. Then modify the date in the “countdown(yyyy,mm,dd)” statement.
Then Place this bit of code in the body where you would like the count down to appear.
If you use this code on your page, please keep the credits to the original author in place.
Enjoy!
© 2006, Robert Owen. All rights reserved.