I want to get records which exists between given start time and end time, start time and end time will be given by user, i'm using the following query for that :
$this->db->where('TIME(start) BETWEEN "' . date('H:i:s', strtotime($start_time)) . '" and "' . date('H:i:s', strtotime($end_time)) . '"');
$this->db->where('TIME(end) BETWEEN "' . date('H:i:s', strtotime($start_time)) . '" and "' . date('H:i:s', strtotime($end_time)) . '"');
$results = $this->db->get('class')->result();
start and end time column is datetime field:
eg. in database start time : 2020-06-08 06:15:00 end time : 2020-06-08 09:15:00