Dynamic timeslot generation

I want to make a dynamically booking based on the length that user selected.

My service starts at 08:00 AM to 05:00 PM.

This first user select a 25 minutes of my service, my current code will generate this:

08:00 AM - 08:25 AM
08:25 AM - 08:50 AM
09:15 AM - 09:40 AM andso on.

the user selected the 09:15 AM - 09:40 AM.

The second user select a 35 minutes of my service and my code will generate this:

08:00 AM - 08:35 AM
08:35 AM - 09:10 AM
09:45 AM - 10:20 AM andso on.

The problem is I don't want to collide the time with already selected time. The already booked time is: 09:15 AM - 09:40 AM and the next generation time should skip this time.

In my database, this is what my column is:

=========================
| id | date | start_time | end_time |
=========================

My current code:

In this code, it just generate timeslot depending on the $duration, it doesn't check if the time generated already in the database or colliding in the existing timeslot.

function generateTimeSlot($duration, $start,$end)
{
    $start = new DateTime($start);
    $end = new DateTime($end);
    $start_time = $start->format('H:i');
    $end_time = $end->format('H:i');
    $i=0;
    while(strtotime($start_time) <= strtotime($end_time)){
        $start = $start_time;
        $end = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));
        $start_time = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));

        if(strtotime($start_time) <= strtotime($end_time)){
            $time[$i]['start'] = $start;
            $time[$i]['end'] = $end;
        }
        $i++;
    }
    return $time;
}

UPDATE CODE:

function generateTimeSlot($duration, $start,$end)
{
    $start = new DateTime($start);
    $end = new DateTime($end);
    $start_time = $start->format('H:i');
    $end_time = $end->format('H:i');
    $i=0;

    global $conn;
    $tmpdate = $_POST['date'];


    while(strtotime($start_time) <= strtotime($end_time)){
        $start = $start_time;
        $end = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));
        $start_time = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));

        if(strtotime($start_time) <= strtotime($end_time)){

            $sql = "SELECT * FROM my_Services WHERE date='$tmpdate'";
            $result = $conn->query($sql);

            if ($result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
                    if (($start <= $row["end_time"]) && ($start >= $row["start_time"]) ) {
                        // this is where i got trouble.
                        // this should skip the timeslot that is already in the database to prevent an overlapping timeslot
                    }else{
                        $time[$i]['start'] = $start;
                        $time[$i]['end'] = $end;
                    }
                }
            }

        }
        $i++;
    }
    return $time;
}

ANOTHER ATTEMPT:

function generateTimeSlot($duration, $start,$end)
{
    $start = new DateTime($start);
    $end = new DateTime($end);
    $start_time = $start->format('H:i');
    $end_time = $end->format('H:i');
    $i=0;

    global $conn;
    $tmpdate = $_POST['date'];
    $sql = "SELECT * FROM my_Services WHERE date='$tmpdate'";
    $result = $conn->query($sql);

    $test = array();
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $test[] = array(
                'start' => $row["starttime"],
                'end' => $row["endtime"]
            );
        }
    }

    while(strtotime($start_time) <= strtotime($end_time)){
        $start = $start_time;
        $end = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));
        $start_time = date('H:i',strtotime('+'.$duration.' minutes',strtotime($start_time)));

        if(strtotime($start_time) <= strtotime($end_time)){
            foreach ($test as $test) {
                if (strtotime($start) < strtotime($test['start']) && strtotime($end) > strtotime($test['end'])) {
                    // code...
                }else{
                    $time[$i]['start'] = $start;
                    $time[$i]['end'] = $end;
                }
            }
        }
        $i++;
    }
    return $time;
}