Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 比较CodeIgniter中的日期_Php_Mysql_Codeigniter_Date - Fatal编程技术网

Php 比较CodeIgniter中的日期

Php 比较CodeIgniter中的日期,php,mysql,codeigniter,date,Php,Mysql,Codeigniter,Date,我想比较我的CodeIgniter模型中的日期。在my db中,日期存储为MM/DD/YYYY。比较日期取自使用MM/DD/YYYY格式的日期选择器 但是我的模型查询不起作用。此处不进行日期比较 比较的格式是什么 型号 $this->db->where('order_date >=', $first_date); $this->db->where('order_date <=', $second_date); $this->db->where('

我想比较我的CodeIgniter模型中的日期。在my db中,日期存储为MM/DD/YYYY。比较日期取自使用MM/DD/YYYY格式的日期选择器

但是我的模型查询不起作用。此处不进行日期比较

比较的格式是什么

型号

   $this->db->where('order_date >=', $first_date);
   $this->db->where('order_date <=', $second_date);
$this->db->where('order\u date>=',$first\u date);
$this->db->where('订单日期使用

$this->db->where("STR_TO_DATE(order_date,'%m/%d/%Y') >=", 
STR_TO_DATE($first_date,'%m/%d/%Y'));

$this->db->where("STR_TO_DATE(order_date,'%m/%d/%Y') >=", 
STR_TO_DATE($second_date,'%m/%d/%Y'));

只需使用
str\u to\u date
函数,如

$this->db->where("order_date BETWEEN str_to_date('$first_date','%m/%d/%Y') AND str_to_date('$second_date','%m/%d/%Y')");

用户输入

$fDate = $this->input->post("first_date"); // Input date format as mm/dd/yy
$sDate = $this->input->post("first_date"); // Input date format as mm/dd/yy
$first_date = date_format($fDate,"m/d/Y"); // Output date format as mm/dd/yy
$second_date = date_format($sDate,"m/d/Y"); // Output date format as mm/dd/yy

转换用户输入

$fDate = $this->input->post("first_date"); // Input date format as mm/dd/yy
$sDate = $this->input->post("first_date"); // Input date format as mm/dd/yy
$first_date = date_format($fDate,"m/d/Y"); // Output date format as mm/dd/yy
$second_date = date_format($sDate,"m/d/Y"); // Output date format as mm/dd/yy

在代码中

$this->db->where('order_date >=', $first_date);
$this->db->where('order_date <=', $second_date);


检查日期选择器格式是否为
datepicker popup=“mm/dd/yyyy”

您的字段类型是什么?(例如日期、日期时间、VARCHAR)我选择VARCHAR大小255使用
DATE\u格式(curdate(),“%m/%d/%Y”)
Where..?请提供详细信息sas@Saty说,请使用正确的日期格式。如果您觉得困难,可以使用时间戳格式来订购日期。订购日期,'%m/%d/%Y',这里有一些意外的%使用此格式,我得到了0而不是日期格式($first_date,'%m/%d/%Y');和日期格式(订单日期,'%m/%d/%Y')>=0和日期格式(订单日期,'%m/%d/%Y')>=0STR\u到日期('12/01/2015','%m/%d/%Y')),或者试试这个@rose。这会出现一些错误。是的<代码>订单日期
在截止日期(2015年1月12日,%m/%d/%Y')和截止日期(2015年2月12日,%m/%d/%Y')之间的回送结果。bt没有发生比较日期我的回答日期需要包含在quotesTry中,以回送查询并将其发布到MySql中,并检查它是否在那里工作我使用此查询得到的结果