vip26
09-18-2005, 02:48 AM
Hello I have a script that I found that grabs server time and then countdowns to the endtime (sept 20th in the script below) and when the endtime arrives it says Expired. Currently the way this script works is every 72 hours I have to go and add 3 days to the endtime to keep it running if I want it to countdown again. Question is: When it reaches Expired, How can I have the script wait 5 Mins and add 3 days to the endtime and in theroy, start another 72 hour countdown again! Without having to matain it anymore.
Thanks ahead of time.
- Jason
<?php
$endtime = "September 20th 2005";
$enddate = strtotime($endtime);
$off_d = date("d",$enddate);
$off_m = date("m",$enddate);
$off_y = date("y",$enddate);
$off_th = date("H",$enddate);
$off_tm = date("i",$enddate);
$off_ts = date("s",$enddate);
$curdate = time();
$now_d = date("d",$curdate);
$now_m = date("m",$curdate);
$now_y = date("y",$curdate);
$now_th = date("H",$curdate);
$now_tm = date("i",$curdate);
$now_ts = date("s",$curdate);
?>
<script language="JavaScript1.2">
now_d = <? echo $now_d; ?>;
now_m = <? echo $now_m; ?>;
now_y = <? echo $now_y; ?>;
now_th = <? echo $now_th; ?>;
now_tm = <? echo $now_tm; ?>;
now_ts = <? echo $now_ts; ?>;
off_y = <? echo $off_y; ?>;
off_m = <? echo $off_m; ?>;
off_d = <? echo $off_d; ?>;
off_th = <? echo $off_th; ?>;
off_tm = <? echo $off_tm; ?>;
off_ts = <? echo $off_ts; ?>;
dateNow = new Date(parseInt(now_y) + 2000,parseInt(now_m) - 1,now_d,now_th,now_tm,now_ts);
dateFuture = new Date(parseInt(off_y) + 2000,parseInt(off_m) - 1,off_d,off_th,off_tm,off_ts);
amount = dateFuture - dateNow;
amount2 = amount;
function update_time() {
amount = amount2 - 1000;
amount2 = amount;
if(amount < 0){
set_inner('countdown', 'Expired!');
// window.location.reload();
}else{
hrs=0;
mins=0;
secs=0;
amount = Math.floor(amount/1000);
hrs=parseInt(Math.floor(amount/3600));
amount=amount % 3600;
mins=parseInt(Math.floor(amount/60));
if (hrs < 10) hrs = '0'+hrs;
if (mins < 10) mins = '0'+mins;
amount=amount % 60;
secs=parseInt(Math.floor(amount));
if (secs < 10) secs = '0'+secs;
set_inner('countdown', hrs+':'+mins+':'+secs);
}
setTimeout('update_time()', 1000);
}
function set_inner(name, value, add){
var elem;
if (document.getElementById) elem = document.getElementById(name);
if (document.all) elem = document.all[name];
if (elem && add) elem.innerHTML += value;
if (elem && !add) elem.innerHTML = value;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<TABLE cellSpacing=0 cellPadding=0 width=97 border=0 style="color: #000000; font-weight: bold">
<TBODY>
<SCRIPT>update_time();</SCRIPT>
<TR>
<TD align=middle style="color: #333333; font-family: Verdana; font-size: 13pt; font-weight: bold" valign="top"><SPAN
id=countdown><font size="4">TIME</font></SPAN></TD></TR></TBODY></TABLE></td>
</body>
</html>
Here is a link to the working countown http://vip26.com/count.php
Thanks ahead of time.
- Jason
<?php
$endtime = "September 20th 2005";
$enddate = strtotime($endtime);
$off_d = date("d",$enddate);
$off_m = date("m",$enddate);
$off_y = date("y",$enddate);
$off_th = date("H",$enddate);
$off_tm = date("i",$enddate);
$off_ts = date("s",$enddate);
$curdate = time();
$now_d = date("d",$curdate);
$now_m = date("m",$curdate);
$now_y = date("y",$curdate);
$now_th = date("H",$curdate);
$now_tm = date("i",$curdate);
$now_ts = date("s",$curdate);
?>
<script language="JavaScript1.2">
now_d = <? echo $now_d; ?>;
now_m = <? echo $now_m; ?>;
now_y = <? echo $now_y; ?>;
now_th = <? echo $now_th; ?>;
now_tm = <? echo $now_tm; ?>;
now_ts = <? echo $now_ts; ?>;
off_y = <? echo $off_y; ?>;
off_m = <? echo $off_m; ?>;
off_d = <? echo $off_d; ?>;
off_th = <? echo $off_th; ?>;
off_tm = <? echo $off_tm; ?>;
off_ts = <? echo $off_ts; ?>;
dateNow = new Date(parseInt(now_y) + 2000,parseInt(now_m) - 1,now_d,now_th,now_tm,now_ts);
dateFuture = new Date(parseInt(off_y) + 2000,parseInt(off_m) - 1,off_d,off_th,off_tm,off_ts);
amount = dateFuture - dateNow;
amount2 = amount;
function update_time() {
amount = amount2 - 1000;
amount2 = amount;
if(amount < 0){
set_inner('countdown', 'Expired!');
// window.location.reload();
}else{
hrs=0;
mins=0;
secs=0;
amount = Math.floor(amount/1000);
hrs=parseInt(Math.floor(amount/3600));
amount=amount % 3600;
mins=parseInt(Math.floor(amount/60));
if (hrs < 10) hrs = '0'+hrs;
if (mins < 10) mins = '0'+mins;
amount=amount % 60;
secs=parseInt(Math.floor(amount));
if (secs < 10) secs = '0'+secs;
set_inner('countdown', hrs+':'+mins+':'+secs);
}
setTimeout('update_time()', 1000);
}
function set_inner(name, value, add){
var elem;
if (document.getElementById) elem = document.getElementById(name);
if (document.all) elem = document.all[name];
if (elem && add) elem.innerHTML += value;
if (elem && !add) elem.innerHTML = value;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<TABLE cellSpacing=0 cellPadding=0 width=97 border=0 style="color: #000000; font-weight: bold">
<TBODY>
<SCRIPT>update_time();</SCRIPT>
<TR>
<TD align=middle style="color: #333333; font-family: Verdana; font-size: 13pt; font-weight: bold" valign="top"><SPAN
id=countdown><font size="4">TIME</font></SPAN></TD></TR></TBODY></TABLE></td>
</body>
</html>
Here is a link to the working countown http://vip26.com/count.php