Created
August 7, 2012 15:05
-
-
Save jonkiddy/3286133 to your computer and use it in GitHub Desktop.
JS Countdown Placement Holder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="countdown" style="position:absolute;padding-top:410px;padding-left:555px;"> | |
<div id="thecount" style="color:white;font-size:28px;font-family:Arial;font-weight:bold;"></div> | |
<script type="text/javascript"> | |
//change the text below to reflect your own, | |
var before="Christmas!" | |
var current="Today is Christmas. Merry Christmas!" | |
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") | |
function countdown(yr,m,d){ | |
theyear=yr;themonth=m;theday=d | |
var today=new Date() | |
var todayy=today.getYear() | |
if (todayy < 1000) | |
todayy+=1900 | |
var todaym=today.getMonth() | |
var todayd=today.getDate() | |
var todayh=today.getHours() | |
var todaymin=today.getMinutes() | |
var todaysec=today.getSeconds() | |
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec | |
futurestring=montharray[m-1]+" "+d+", "+yr | |
dd=Date.parse(futurestring)-Date.parse(todaystring) | |
dday=Math.floor(dd/(60*60*1000*24)*1) | |
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1) | |
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1) | |
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1) | |
if(dday==0&&dhour==0&&dmin==0&&dsec==1){ | |
document.getElementById('thecount').innerHTML = current | |
return | |
} | |
else | |
document.getElementById('thecount').innerHTML=dday+ " DAYS, "+(dhour+1)+" HRS, "+dmin+" MIN" | |
setTimeout("countdown(theyear,themonth,theday)",1000) | |
} | |
//enter the count down date using the format year/month/day | |
countdown(2012,7,27) | |
</script> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment