php - 如何在 CodeIgniter 中仅从日期时间获取日期?

标签 php mysql codeigniter

我在 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/

相关文章:

php - 自定义配置文件 - Codeigniter

php - 为什么 php 的 imap_open() 不像 SSL?

php - Symfony2 : how to implement custom user login & registration - get rid of FOSUSerBundle

mysql - 从查询中获取列列表而不在mysql中运行查询

php - MySql COALESCE 不工作

php - CodeIgniter,了解调用函数的 Controller

javascript - 在基于 PHP 的网站上呈现 Cookie

php - elseif 与 else if 之间的根本区别

mysql - 查询优化器出现奇怪的 mysql 问题

php - CodeIgniter 分页 url 页码