Jump to content

php countdown


grlayouts

Recommended Posts

how can i edit the below to run a php file when it runs out

 

<?php
// Setup the expire date/time
$expiredate = "2002-08-30";
$expiretime = "21:30";

// calculate seconds to expire date/time
$exptime = explode(":",$expiretime);
$expdate = explode("-",$expiredate);
$expiretimestamp = mktime($exptime[0],$exptime[1],0,$expdate[1],$expdate[2],$expdate
[0],-1);
$seconds_left = $expiretimestamp - time();

// has expire date/time passed?
$countdown = ($seconds_left >= 0) ? true : false;
?>
<head>
<title>COUNTDOWN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<?php
if ($countdown) // if the expire date/time hasn't been reached
        {
?>
<script language="JavaScript">
<!--
function showtime() {        
setTimeout("showtime();",1000);
sourcedate.setTime(sourcedate.getTime()-1000);
var hh = (sourcedate.getDate()-1)*24 + sourcedate.getHours()-1;
if ( hh < 0 ) {
document.all["clock"].innerText = '';
this.location.href = this.location.href; // Reload the page
}
var mm = sourcedate.getMinutes();
var ss = sourcedate.getSeconds();
if (hh >= 0) {
document.all["clock"].innerText = ((hh < 10) ? "0" : "") + hh + ((mm <
10) ? ":0" : ":") +
mm + ((ss < 10) ? ":0" : ":") + ss;
}
}

sourcedate = new Date(<?= date("Y,m,d,H,i,s",$seconds_left);?>);
//-->
</script>
<?php
        } // end if ($countdown)
?>
</head>

<body>
<?php
if ($countdown) // if the expire date/time hasn't been reached
        {
?>
The expiredate/time is: <?= $expiredate . ' ' . $expiretime; ?><br>
Time to go: <span name="clock" id="clock" class="top_tbl">Countdown here</span>
<?php
        }
else // Show some other content
        {
?>
We have passed the expiredate/time: <?= $expiredate . ' ' . $expiretime; ?>
<?php
        }
?>

<script language="JavaScript">
<!--
showtime(); // Init the function
//-->
</script>
</body>

Link to comment
https://forums.phpfreaks.com/topic/43043-php-countdown/
Share on other sites

Like  a cron :\ ?

if its jsut a countdown make it easier:

<?php
session_start();
$year = date('Y');
$month = date('m');
$day = date('d');
$hour = date('H');
$minutes = date('m');

if ($year == "2007" AND $month == "2" AND $day == "30" AND $hour == "00" AND $minutes == "00"){
print "what @#@$ Its 30th of feb";}

 

jsut correct the date functions!

Link to comment
https://forums.phpfreaks.com/topic/43043-php-countdown/#findComment-209172
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.