jeudi 22 septembre 2016

How can i restrict user that he can not book time before current time

I am showing user time by the interval of 30 minutes.I am taking start time and end time from the database.I am showing time from the start time to end time by the interval of 30 minutes.In which i am showing available time and booked time also.I want user that he can not book time before current time on current date.

  <?php  
        $starttime = $query2['starttime'];  // your start time
        $endtime = $query2['endtime'];  // End time
        $duration = '30';  // split by 30 mins
       $array_of_time = array ();
       $start_time    = strtotime ($starttime); //change to strtotime
       $end_time      = strtotime ($endtime); //change to strtotime

      $add_mins  = $duration * 60;
      while ($start_time <= $end_time) // loop between time
     {
     $array_of_time[] = date ("h:i a", $start_time);
     $start_time += $add_mins; // to check endtime
     }
     $arr_ctr=count($array_of_time)-1;

     foreach ($array_of_time as $key => $single_time) { 
     if($arr_ctr>$key){
     ?>  
       <tr>
     <td style="border:1px solid;padding:11px;">
   <?php         
        $array_filter = $array_of_time[$key] . ' - ' . $array_of_time[$key+1];
        $is_booked = false;

        $query5=mysql_query("select atime from doctorbooking where aday='".$_SESSION['new22']."' and demail='".$query2['email']."'");

        while( $query6 = mysql_fetch_array($query5) ) {           
        if ( $array_filter == $query6['atime'] ) {
        //it force "booked" as soon as 1 is booked
        $is_booked = true;
        } else {
    }           
   }

     if ($is_booked) {
  echo $array_filter . '<br /><span style="color:red;background-color:#C0C0C0;">Booked</span>';
  } else {
echo $array_filter . '<br /><span style="color:red;">Available</span>';
 }

?>

Everything is working good but i only want user that if the current time is 1:30 pm and current date is 22/09/16.That he can not book time before 1:30 pm on current date.My start time is 10:00 am and my end time is 5:00 pm.Please Help.Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire