我在 MySQL 表中有数据,如下所示:
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
当我尝试在模块中获取值时,它不起作用,我编写如下代码:
$query=$this->db->get_where('datas', array('dates' => date('Y-m-d')));
我需要获取全天的数据,例如仅获取 2011 年 12 月 18 日的数据。
谢谢
最佳答案
试试这个:
$date="2018-09-19";
$this->db->select('*');
$this->db->from('tbl_name');
$this->db->where('DATE(date_time_col)', $date);
$query = $this->db->get();
$res= $query->result();
关于php - 如何在 CodeIgniter 中仅从日期时间获取日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8551195/