sharp.mac Posted August 26, 2010 Share Posted August 26, 2010 #1 my function to find out if my store is closed function determineTime() { $hour = date("H"); if (($hour < '09' || $hour >= '21')) { return true; } else { return false; } } #2 my case switch to find out if the "trip" departs in less then <24 hours or <48 hours etc..... $myDiff = dateDiff(date("m/d/Y H:i:s"), "$dep_date 05:00:00"); list($myHour, $myMinute) = split(',', $myDiff); //echo $myHour.'<br/>'; //echo $myMinute; if(!isset($myHour)) $myHour = 0; $nowTime = date("H:i:s"); $futureTime = date("H:i:s", strtotime("$nowTime + 2 hours")); //echo '<h1>*'.$nowTime.'*</h1>'; //echo '<h1>*'.$futureTime.'*</h1>'; //$departures = $db->query("$dep_query $dep_where $dep_order"); // NO TIME RESTRICTIONS switch($myHour){ default: case "": break; case ($myHour <= 24): $_SESSION['addToTotal'] = $passengers*5; if(determineTime()){ //we are closed //if the store is closed and it is TODAY do not allow the users to book a trip before 9am $departures = $db->query("$dep_query $dep_where AND trips.times > '09:00:00' $dep_order"); //run query }else{ //we are open //if open allow the user to book, but only for trips that are for 2 HOURS out and GREATER $departures = $db->query("$dep_query $dep_where AND (trips.times > '$futureTime' OR trips.times > '09:00:00') $dep_order"); //run query } break; case ($myHour > 24 && $myHour < 48): $_SESSION['addToTotal'] = $passengers*5; $departures = $db->query("$dep_query $dep_where $dep_order"); //run query break; } All my times are in H:i:s format. Somewhere for some reason that when we are closed users can still book trips that are for 5am. Quote Link to comment https://forums.phpfreaks.com/topic/211758-php-timing-script/ Share on other sites More sharing options...
sharp.mac Posted August 28, 2010 Author Share Posted August 28, 2010 can someone point me into a glitch they see or how i might be thinking about this incorrectly? Quote Link to comment https://forums.phpfreaks.com/topic/211758-php-timing-script/#findComment-1104512 Share on other sites More sharing options...
jcbones Posted August 28, 2010 Share Posted August 28, 2010 For glitches we need to see the full script. Partial code does not tell us how the variables are formed, nor if they are defined at all. Quote Link to comment https://forums.phpfreaks.com/topic/211758-php-timing-script/#findComment-1104652 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.