I want to get the time from 12:00:00 PM to 02:00:00 PM but it doesn't work when I use start_time >= '12:00:00' AND end_time <= '02:00:00'
. I have this code so far.
Note: I'm using Code Igniter.
$start = date("g:i:s", strtotime($this->input->post('start')));
$end = date("g:i:s", strtotime($this->input->post('end')));
$date_reserve = $this->input->post('date_reserve');
$sql = "SELECT materialID FROM schedule WHERE date_reserve = ? AND start_time >= ? AND end_time <= ?";
$query = $this->db->query($sql,array($date_reserve,$start,$end));
I use g:i:s
to format it in a 12hr time format. And when I try to echo it, gives me 12:00:00
and 02:00:00
it doesn't get the AM/PM
. And also the data type of start_time and end_time in my DB is time
. What is the proper way to retrieve the data and what data type should I use in my DB. Thanks!.