Search code examples
phpmysqlcodeigniter

How to get only date from datetime in CodeIgniter?


I have data in MySQL table like :

ID     dates                   value
1    2011-12-18 10:11:12      test1
2    2011-12-18 12:11:12      test2
3    2011-11-18 10:19:11      test3

When I tried to get value in module it not work, I write code like :

$query=$this->db->get_where('datas', array('dates' => date('Y-m-d')));

I need to get data from whole day like get data only from 2011-12-18.

Thanks


Solution

  • try with $this->db->like();

    so it will be

    $query=$this->db->like('dates', array('dates' => date('Y-m-d')));
    

    the % will be added automatically

    also you have datas as key, and should be dates based on database structure