Jump to content

Problems with a countdown timer


TimUSA

Recommended Posts

I though I had this set so that only one clock would run for a given set of conditions. Whats happening is it is setting the time correctly, but loading the first javascript for every condition rathar than what is inside the else if:

$currentdate = array("a" => gmdate("l H:i"));

$starttime = array("Saturday 21:00" , "Tuesday 21:00" , "Thursday 21:00");
$stoptime = array("Sunday 02:00" , "Wednesday 02:00" , "Friday 02:00");

$starttime2 = array("Sunday 02:00" , "Wednesday 02:00" , "Friday 02:00");
$stoptime2 = array("Sunday 07:00" , "Wednesday 07:00" , "Friday 07:00");

$starttime3 = array("Sunday 06:00" , "Tuesday 06:00" , "Friday 06:00");
$stoptime3 = array("Sunday 10:00" , "Tuesday 10:00" , "Friday 10:00");

$starttime4 = array("Sunday 18:00" , "Wednesday 18:00" , "Friday 18:00");
$stoptime4 = array("Sunday 21:00" , "Wednesday 21:00" , "Friday 21:00");

if ((in_array($currentdate) >= in_array($starttime)) > in_array($stoptime))
{
$setclock = gmdate("m/d/Y 01:00 e");
echo'
	<center>
		<script language="JavaScript">
			TargetDate = "' . $setclock .'";
			ForeColor = "black";
			CountActive = true;
			CountStepper = -1;
			LeadingZero = true;
			DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes until Zone A races.";
			FinishMessage = "Zone A races have started.";
		</script>
		<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js">
		</script>
	</center>';
}
else if ((in_array($currentdate) >= in_array($starttime2)) > in_array($stoptime2))
{

$setclock2 = gmdate("m/d/Y 06:00 e");
echo'
	<center>
		<script language="JavaScript">
			TargetDate = "' . $setclock2 .'";
			ForeColor = "black";
			CountActive = true;
			CountStepper = -1;
			LeadingZero = true;
			DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes until Zone B races.";
			FinishMessage = "Zone B races have started.";
		</script>
		<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js">
		</script>
	</center>';
}
else if ((in_array($currentdate) >= in_array($starttime3)) > in_array($stoptime3))
{
$setclock3 = gmdate("m/d/Y 09:00 e");
echo'
	<center>
		<script language="JavaScript">
			TargetDate = "' . $setclock3 .'";
			ForeColor = "black";
			CountActive = true;
			CountStepper = -1;
			LeadingZero = true;
			DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes until Zone C races.";
			FinishMessage = "Zone C races have started.";
		</script>
		<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js">
		</script>
	</center>';
}
else if ((in_array($currentdate) >= in_array($starttime4)) > in_array($stoptime4))
{
$setclock4 = gmdate("m/d/Y 20:00 e");
echo'
	<center>
		<script language="JavaScript">
			TargetDate = "' . $setclock4 .'";
			ForeColor = "black";
			CountActive = true;
			CountStepper = -1;
			LeadingZero = true;
			DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes until Zone D races.";
			FinishMessage = "Zone D races have started.";
		</script>
		<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js">
		</script>
	</center>';
}

 

so if this script were running at 19:00 GMT its saying 1 hour to Zone A instead of Zone D

Link to comment
https://forums.phpfreaks.com/topic/86337-problems-with-a-countdown-timer/
Share on other sites

ok i think i am totaly not getting this:

 

how do i say if $currenttime is greater than $starttime and less than $stoptime in the array, than do this?

<?php

$currentdate = gmdate("l H:i");

$starttime = array(	"a" => "Saturday 21:00" , 
				"b" => "Tuesday 21:00" , 
				"c" => "Thursday 21:00");

$stoptime = array(	"a" => "Sunday 02:00" , 
				"b" => "Wednesday 02:00" , 
				"c" => "Friday 02:00");					

$starttime2 = array("a" => "Saturday 02:00" , 
				"b" => "Tuesday 02:00" , 
				"c" => "Thursday 02:00");

$stoptime2 = array(	"a" => "Sunday 07:00" , 
				"b" => "Wednesday 07:00" , 
				"c" => "Friday 07:00");

$starttime3 = array("a" => "Saturday 07:00" , 
				"b" => "Tuesday 07:00" , 
				"c" => "Thursday 07:00");

$stoptime3 = array(	"a" => "Sunday 10:00" , 
				"b" => "Wednesday 10:00" , 
				"c" => "Friday 10:00");

$starttime4 = array("a" => "Saturday 10:00" , 
				"b" => "Tuesday 10:00" , 
				"c" => "Thursday 10:00");

$stoptime = array(	"a" => "Sunday 21:00" , 
				"b" => "Wednesday 21:00" , 
				"c" => "Friday 21:00");


if ($currentdate > ///how do i do this?)
{
$setclock = gmdate("m/d/Y 01:00 e");
$racename = "Zone A";
}
else if ($currentdate > ///how do i do this?)
{
$setclock = gmdate("m/d/Y 06:00 e");
$racename = "Zone B";
}
else if ($currentdate > ///how do i do this?)
{
$setclock = gmdate("m/d/Y 09:00 e");
$racename = "Zone C";
}
else if ($currentdate > ///how do i do this?)
{
$setclock = gmdate("m/d/Y 20:00 e");
$racename = "Zone D";
}
echo'
<center>
	<script language="JavaScript">
		TargetDate = "' . $setclock .'";
		ForeColor = "black";
		CountActive = true;
		CountStepper = -1;
		LeadingZero = true;
		DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes until ' . $racename . ' races.";
		FinishMessage = "' . $racename . ' races have started.";
	</script>
	<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js">
	</script>
</center>';

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.