Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
[CODE] Countdown Timer; WANT WANT WANT
Topic Started: Apr 9 2003, 07:26 AM (4,362 Views)
Tidal Wave 4Him
Member
 *   *  
ok, how do you get it to count down automatically, so you don't have to refresh the page?
Offline Profile Quote Post Goto Top
 
Gohan
Member
 *  
Admin CP> Board Wrappers

Put it in either your Head or Footer :)

Quote:
 
<br><center>
<script language="JavaScript">
// This Script And Over 400 Others Found At
//  Java City 2000 http://www.jc2k.com
<!-- Activate Cloaking


var timerID;
var timerRunning = false;
var today = new Date();
var count = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var dayRemain = 0;
var minRemain = 0;
var Expire = 0;
var timeRemain = 0;
var timeUp = "ENTER WHAT YOU WANT HERE"    // enter text to be displayed when countdown is finished
var time = "0 days, 0 hours, 0 minutes, 0 seconds" //do not modify this text

function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

function startclock () {
stopclock();
showtime();
}


function showtime () {
today = new Date();
count = new Date("June 20, 2003 12:00");  // enter date to count down to ("June 20, 2003 12:00")
count.setYear(today.getYear());
secsPerDay = 1000;
minPerDay = 60 * 1000;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
Expire = (count.getTime() - today.getTime())

/*Seconds*/

secsLeft = (count.getTime() - today.getTime()) / minPerDay;

secsRound = Math.round(secsLeft);

secsRemain = secsLeft - secsRound;

secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft)
* 60) : secsRemain = (secsLeft - secsRound) * 60;

secsRemain = Math.round(secsRemain);


/*Minutes*/

minLeft = ((count.getTime() - today.getTime()) / hoursPerDay);

minRound = Math.round(minLeft);

minRemain = minLeft - minRound;

minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft)  *
60) : minRemain = ((minLeft - minRound) * 60);

minRemain = Math.round(minRemain - 0.495);


/*Hours*/

hoursLeft = ((count.getTime() - today.getTime()) / PerDay);

hoursRound = Math.round(hoursLeft);

hoursRemain = hoursLeft - hoursRound;

hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound -
hoursLeft)  * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);

hoursRemain = Math.round(hoursRemain - 0.5);

/*Days*/

daysLeft = ((count.getTime() - today.getTime()) / PerDay);

daysLeft = (daysLeft);

daysRound = Math.round(daysLeft);

daysRemain = daysRound;


/*Fixes*/

if (daysRemain == 1) daysRemain = daysRemain + " day, ";
      else daysRemain = daysRemain + " days, ";

if (hoursRemain == 1) hoursRemain = hoursRemain + " hour,  ";
      else hoursRemain = hoursRemain + " hours,  ";

if (minRemain == 1) minRemain = minRemain + " minute,  ";
      else minRemain = minRemain + " minutes,  ";

if (secsRemain == 1) secsRemain = secsRemain + " second";
      else secsRemain = secsRemain + " seconds";


/*Time*/

timeRemain = daysRemain + hoursRemain + minRemain +
secsRemain;

window.status = "";
document.clock.face.value = timeRemain;
timerID = setTimeout("showtime()",1000);
timerRunning = true;

if (Expire <= 0){
document.clock.face.value = time;  // choose either "time" or "timeUp"  (without quotes)
stopclock()
}

}
// De-activate Cloaking -->
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#000080" ALINK="#000080">
<FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face"></FORM>

<script language="JavaScript">
// This Script And Over 400 Others Found At
//  Java City 2000 http://www.jc2k.com
<!--
//document.write('<FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face"></FORM>');
startclock()
// -->
</SCRIPT>
Offline Profile Quote Post Goto Top
 
Tidal Wave 4Him
Member
 *   *  
god, what the hell? it's not counting down at all. this is starting to piss me off...
Offline Profile Quote Post Goto Top
 
pikapi
I'm going to miss you...
 *   *   *  
i Was testin it in my test forum at my board but it doesn't work
Offline Profile Quote Post Goto Top
 
DemonSlayer
Member Avatar
Member
 *  
If someone could please tell me how to make this clock countdown automatically, it would be of great help.
Offline Profile Quote Post Goto Top
 
Anfield
Captain Fantastic
 *   *   *  
Code:
 
<center>The Great American Bash is in</center>
</br><center>
<script language="JavaScript">
// This Script And Over 400 Others Found At
//  Java City 2000 http://www.jc2k.com
<!-- Activate Cloaking


var timerID;
var timerRunning = false;
var today = new Date();
var count = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var dayRemain = 0;
var minRemain = 0;
var Expire = 0;
var timeRemain = 0;
var timeUp = "Great American Bash"    // The Great American Bash is over
var time = "0 days, 0 hours, 0 minutes, 0 seconds" //do not modify this text

function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

function startclock () {
stopclock();
showtime();
}


function showtime () {
today = new Date();
count = new Date("June 20, 2003 12:00");  // enter date to count down to ("June 28, 2004 01:00")
count.setYear(today.getYear());
secsPerDay = 1000;
minPerDay = 60 * 1000;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
Expire = (count.getTime() - today.getTime())

/*Seconds*/

secsLeft = (count.getTime() - today.getTime()) / minPerDay;

secsRound = Math.round(secsLeft);

secsRemain = secsLeft - secsRound;

secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft)
* 60) : secsRemain = (secsLeft - secsRound) * 60;

secsRemain = Math.round(secsRemain);


/*Minutes*/

minLeft = ((count.getTime() - today.getTime()) / hoursPerDay);

minRound = Math.round(minLeft);

minRemain = minLeft - minRound;

minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft)  *
60) : minRemain = ((minLeft - minRound) * 60);

minRemain = Math.round(minRemain - 0.495);


/*Hours*/

hoursLeft = ((count.getTime() - today.getTime()) / PerDay);

hoursRound = Math.round(hoursLeft);

hoursRemain = hoursLeft - hoursRound;

hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound -
hoursLeft)  * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);

hoursRemain = Math.round(hoursRemain - 0.5);

/*Days*/

daysLeft = ((count.getTime() - today.getTime()) / PerDay);

daysLeft = (daysLeft);

daysRound = Math.round(daysLeft);

daysRemain = daysRound;


/*Fixes*/

if (daysRemain == 1) daysRemain = daysRemain + " day, ";
     else daysRemain = daysRemain + " days, ";

if (hoursRemain == 1) hoursRemain = hoursRemain + " hour,  ";
     else hoursRemain = hoursRemain + " hours,  ";

if (minRemain == 1) minRemain = minRemain + " minute,  ";
     else minRemain = minRemain + " minutes,  ";

if (secsRemain == 1) secsRemain = secsRemain + " second";
     else secsRemain = secsRemain + " seconds";


/*Time*/

timeRemain = daysRemain + hoursRemain + minRemain +
secsRemain;

window.status = "";
document.clock.face.value = timeRemain;
timerID = setTimeout("showtime()",1000);
timerRunning = true;

if (Expire <= 0){
document.clock.face.value = time;  // choose either "time" or "timeUp"  (without quotes)
stopclock()
}

}
// De-activate Cloaking -->
// -->
</SCRIPT>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#000080" ALINK="#000080">
<FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face"></form>

<script language="JavaScript">
// This Script And Over 400 Others Found At
//  Java City 2000 http://www.jc2k.com
<!--
//document.write('<FORM NAME="clock"><INPUT TYPE="text" SIZE="41" NAME="face">&lt;/form>');
startclock()
// -->
</SCRIPT>


That counts down auto for me, I also got text above if you want it.

I think the <br> is meant to be </br> dunno. But it works :)

http://s3.invisionfree.com/Wrestle_Zone at bottom for preview
Offline Profile Quote Post Goto Top
 
lordUsadiablo
Member
 *  
it works for me to hmmmm it must really hate u guys :lol: later) :'(
Offline Profile Quote Post Goto Top
 
FFPalace
Member
 *  
This is working for me, expect for one thing: the days. They stay at 61(should be at 60). Here's my site, can anyone tell me whats wrong?

http://s9.invisionfree.com/FF_Palace/index.php
Offline Profile Quote Post Goto Top
 
16.5th Dimension
Member
 *  
Stephen
April 9, 2003 03:29 PM
Try this:

Code:
 
<br><script language="javascript" type="text/javascript"><!--var date = new Date(ENTER DATE);var now = new Date();var diff = date.getTime() - now.getTime();var days = Math.floor(diff / (1000 * 60 * 60 * 24));document.write("<b>" + (days + 1) + " ENTER TEXT HERE</b>" );//--></script><br>


OR

Code:
 
<br>
<script language="javascript" type="text/javascript">
<!--
var date = new Date('ENTER DATE');
var now = new Date();
var diff = date.getTime() - now.getTime();
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
document.write("<b><font color="white">" + (days + 1) + " ENTER TEXT</b></font>" );
//-->
</script>
<br>


Also if you need to center it:
Code:
 
<center>code here </center>




I hope this helps

Could you possibly explain how to use this code? I need a countdown timer, but I don't where I'm supposed to put in stuff, such as the date that I'm counting down to. I would assume the "ENTERDATE" thing, but how would I format the date?
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code Snippets · Next Topic »
Add Reply