We coded time script and made sure that user makes a reservation between opening time and closing time of restaurant. (Timings were decided by us for time being).
<?php
include "myFunctions.php";
date_default_timezone_set('Asia/Kolkata');
//$data = json_decode(file_get_contents("php://input"), true);
$date = myUrlEncode($_POST['date']);
$time = myUrlEncode($_POST['time']);
$today = date("Y-m-d");
$opening_time = Datetime::createFromFormat('H:i', '10:00');
$closing_time = Datetime::createFromFormat('H:i', '19:00');
$booking_time = Datetime::createFromFormat('Y-m-d H:i', $date. ' ' .$time);
$messages = array();
$zero = array("interval"=>"00:30", "showInterval"=>"30 mins");
$one = array("interval"=>"01:00", "showInterval"=>"1 hr");
$two = array("interval"=>"01:30", "showInterval"=>"1 hr 30 mins");
$three = array("interval"=>"02:00", "showInterval"=>"2 hrs");
$four = array("interval"=>"02:30", "showInterval"=>"2 hrs 30 mins");
$five = array("interval"=>"03:00", "showInterval"=>"3 hrs");
$quick_replies[0] = array("title"=>"30 mins", "set_attributes"=>$zero);
$quick_replies[1] = array("title"=>"1 hr", "set_attributes"=>$one);
$quick_replies[2] = array("title"=>"1 hr 30 mins", "set_attributes"=>$two);
$quick_replies[3] = array("title"=>"2 hrs", "set_attributes"=>$three);
$quick_replies[4] = array("title"=>"2 hrs 30 mins", "set_attributes"=>$four);
$quick_replies[5] = array("title"=>"3 hrs", "set_attributes"=>$five);
$pattern = "/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/";
if(preg_match($pattern, $time)){
$resv_time = Datetime::createFromFormat('H:i', date($time));
if(strtotime($date)==strtotime($today)){
if($resv_time <= Datetime::createFromFormat('H:i', date('H:i'))){
$messages[0] = array("text" => "Sorry! But it seems this time has already passed");
$res = array("messages"=>$messages, "redirect_to_blocks"=>array("Time exception"));
}
}
if($resv_time < $opening_time){
$messages[0] = array("text" => "Sorry! Restaurant opens after 10 AM");
$res = array("messages"=>$messages, "redirect_to_blocks"=>array("Time exception"));
} else if($resv_time > $closing_time){
$messages[0] = array("text" => "Sorry! No Reservations after 7 PM");
$res = array("messages"=>$messages, "redirect_to_blocks"=>array("Time exception"));
} else {
$showTime = date("g:i a", strtotime($time));
$attributes = array("showTime"=>$showTime);
$messages[0] = array("text" => "What will be the time interval of stay?", "quick_replies"=>$quick_replies);
$res = array("messages"=>$messages, "set_attributes"=>$attributes);
}
} else {
$messages[0] = array("text" => "Umm..I couldn't understand that.");
$res = array("messages"=>$messages, "redirect_to_blocks"=>array("Time exception"));
}
echo json_encode($res, JSON_UNESCAPED_SLASHES);
?>


