I have one user A. The User A is available for 10:45:00 to 18:45:00. means he can accept appointments during that time.
so suppose, User A has two booked appointments:
(1) 11:15:00 to 12:15:00 and
(2) 13:30:00 to 15:45:00
There is minimum 10 minutes gap between two appointment.
So now User A's free timing is:
(1) 10:45:00 to 11:05:00 ( start time = 10:45:00, end time = 11:05:00 because user A have booked appointment which is start at 11:15:00, there is 10 min gap between time so end time is 11:05:00)
(2) 12:25:00 to 13:20:00 (start time = 12:25:00 because first booked appointment is finished on 12:15:00, there is 10 min gap between time so end time is 12:25:00, end time = 13:20:00 because 2nd booked appointment is started on 13:30:00, there is 10 min gap between time so end time is 13:20:00 )
(3) 15:55:00 to 18:45:00 (same as above)
means
Total Time Slot:
10:45:00 to 18:45:00Booked Time Slot:
11:15:00 to 12:15:00
13:30:00 to 15:45:00Free Time Slot:
10:45:00 to 11:05:00
12:25:00 to 13:20:00
15:55:00 to 18:45:00
PHP CODE
:
$total_time = array(
'time' => '11:15:00',
'end_time' => '12:15:00'
);
$gettime = $this->db->query("select `appointment_id`, `time`, `end_time` from `tbl_appointment` where `date`='".$json['date']."'");
if($gettime->num_rows()>0)
{
foreach($gettime->result_array() as $restime)
{
$booked_time[] = array(
'time' => $restime['time'],
'end_time' => $restime['end_time']
);
}
}
I have no idea about how to implement it, so i have no other code. Just two array.
So question is based on available time and booked time, how to find free time?
Thanks in advance.