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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.