TimUSA Posted January 16, 2008 Share Posted January 16, 2008 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 More sharing options...
GingerRobot Posted January 16, 2008 Share Posted January 16, 2008 The in_array() function expects two parameters, you are only providing one. Not entirely sure what you're trying to achieve, so im not sure of the fix. Link to comment https://forums.phpfreaks.com/topic/86337-problems-with-a-countdown-timer/#findComment-441163 Share on other sites More sharing options...
TimUSA Posted January 16, 2008 Author Share Posted January 16, 2008 get the current time if th $currenttime is greater than or equal to the $starttime, but less than the $stoptime run this script: Link to comment https://forums.phpfreaks.com/topic/86337-problems-with-a-countdown-timer/#findComment-441170 Share on other sites More sharing options...
TimUSA Posted January 17, 2008 Author Share Posted January 17, 2008 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>'; Link to comment https://forums.phpfreaks.com/topic/86337-problems-with-a-countdown-timer/#findComment-442107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.