View Full Version : Anyone got a countdown clock script?
Cyberian
04-16-2003, 08:24 PM
Lets say the dead line is May 01, 2003 at 08:00.
Is there a script that will do that countdown?
HairyTeeth
04-16-2003, 10:18 PM
Here's a script by glenngv:
http://www.codingforums.com/showthread.php?s=&threadid=17179
Cyberian
04-17-2003, 05:09 AM
Thanks for the help. But which section do I delete or add in order to view it on the window rather than on the status bar?
Cyberian
04-18-2003, 06:40 AM
Anyone know? I'm new at computer programming, so I'm not as good as all of you.
Skyzyx
04-18-2003, 06:56 AM
Here's Glenn's script, slightly modified to send the text to a SPAN tag with an ID of "showCountdown". Hope this helps!
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
/**************************************
COUNTDOWN SCRIPT
By Glenn V.
**************************************/
var eos = new Date(new Date().getFullYear(),5,19);
var one_day=1000*60*60*24;
var timer;
function countDown()
{
var today = new Date();
var hours=0;
var mins=0;
var secs=0;
days = (eos.getTime()-today.getTime())/one_day;
if (days>0)
{
intDays = Math.floor(days);
daysFracPart = getFracPart(days);
if (daysFracPart>0)
{
hours = daysFracPart*24;
intHours = Math.floor(hours);
hoursFracPart = getFracPart(hours);
if (hoursFracPart>0)
{
mins = hoursFracPart*60;
intMins = Math.floor(mins);
minsFracPart = getFracPart(mins);
if (minsFracPart>0)
{
secs = minsFracPart*60;
intSecs = Math.round(secs);
if (intSecs==60) intSecs=0;
}
}
}
document.getElementById('showCountdown').innerHTML = intDays + " days " + intHours + " hours " + intMins + " mins " + intSecs + " secs left till the last day of school.";
}
else
{
document.getElementById('showCountdown').innerHTML = "Today is the last day of the school!!!";
if (timer) clearInterval(timer);
}
timer = setTimeout("countDown()",1000);
}
function getFracPart(floatNum)
{
return parseFloat(floatNum.toString().substring(floatNum.toString().indexOf(".")));
}
//-->
</script>
</head>
<body onload="countdown();">
<span id="showCountdown"></span>
</body>
</html>
Cyberian
04-18-2003, 07:02 AM
Thanks for responding. But the script didn't work for me.
Also, is it possible to make everything double digit? Even converting the 1's into 01's.
Skyzyx
04-18-2003, 07:36 AM
It's fixed, and it should do what you want it to.
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
/**************************************
COUNTDOWN SCRIPT
By Glenn V.
**************************************/
var eos = new Date(new Date().getFullYear(),5,19);
var one_day=1000*60*60*24;
var timer;
function countDown()
{
var today = new Date();
var hours=0;
var mins=0;
var secs=0;
days = (eos.getTime()-today.getTime())/one_day;
if (days>0)
{
intDays = Math.floor(days);
if (intDays < 10) intDays='0'+intDays;
daysFracPart = getFracPart(days);
if (daysFracPart>0)
{
hours = daysFracPart*24;
intHours = Math.floor(hours);
if (intHours < 10) intHours='0'+intHours;
hoursFracPart = getFracPart(hours);
if (hoursFracPart>0)
{
mins = hoursFracPart*60;
intMins = Math.floor(mins);
if (intMins < 10) intMins='0'+intMins;
minsFracPart = getFracPart(mins);
if (minsFracPart>0)
{
secs = minsFracPart*60;
intSecs = Math.round(secs);
if (intSecs < 10) intSecs='0'+intSecs;
if (intSecs==60) intSecs=0;
}
}
}
document.getElementById('showCountdown').innerHTML = intDays + " days " + intHours + " hours " + intMins + " mins " + intSecs + " secs left till the last day of school.";
}
else
{
document.getElementById('showCountdown').innerHTML = "Today is the last day of the school!!!";
if (timer) clearInterval(timer);
}
timer = setTimeout("countDown()",1000);
}
function getFracPart(floatNum)
{
return parseFloat(floatNum.toString().substring(floatNum.toString().indexOf(".")));
}
//-->
</script>
</head>
<body onload="countDown();">
<span id="showCountdown"></span>
</body>
</html>
Cyberian
04-18-2003, 07:39 AM
WORKED!!!!!!!!! Thanks a lot!
This is a nice tool to have for my dead lines.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.