[英]Comparing Dates with CodeIgniter
I am trying to compare dates using comparison operators such as => or <. 我正在尝试使用=>或<之类的比较运算符来比较日期。 First thing I don't know if this is possible due to the "/".
第一件事,由于“ /”,我不知道是否可能。 I've been searching for a couple hours no and haven't found anything that allows you to check to see if dates match.
我一直在搜索几个小时,没有发现任何可让您检查日期是否匹配的内容。 I have been able to do this for a single date but haven't found a way to do this for multiple dates.
我已经可以在单个日期中执行此操作,但是还没有找到在多个日期中执行此操作的方法。
Since I am using CodeIgnitor my code look a little something like this. 由于我正在使用CodeIgnitor,因此我的代码看起来像这样。
$date = ('9/28/2013');
$listings = $this->db->get('listings', array('listing_end_date <=', $date))->result_array();
print_r($listings); exit;
Yes, I am aware that $date
is a string but even as a Date variable I could not get this to work for me. 是的,我知道
$date
是一个字符串,但是即使作为Date变量,我也无法使用它。
Assuming that your database is properly architected, the proper date format in MySQL is YYYY-MM-DD. 假设您的数据库已正确构建,则MySQL中正确的日期格式为YYYY-MM-DD。 This means you will want to revise your date format as such.
这意味着您将需要修改日期格式。
$date = '2013-09-28';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.