Jump to content

PHP timing script


sharp.mac

Recommended Posts

#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.

Link to comment
https://forums.phpfreaks.com/topic/211758-php-timing-script/
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.