thinkphp中如何通过日期查询数据库

数据库的表中每一条存有两个日期,一个开始日期starttime,一个endtime ;Date格式,即为Y-m-d现在通过文本框提交一个日期,从数据库中查询两个日期之间包括该日期的数据。。。该怎么做啊,thinkphp我没找到方法,求助我想到的方法如下,但是查询不成功:$time=strtotime($_POST['dates']);//dates为从文本框获得的日期$sql='select * from think_mytask where strtotime(starttime)<=$time and="">=$time'; $admin1=new Model('mytask');$list=$admin1->query($sql);求帮助

第1个回答  推荐于2016-11-04
方法:
$time=strtotime($_POST['dates']);//dates为从文本框获得的日期
$sql='select * from think_mytask where strtotime(starttime)<=$time and strtotime(endtime)>=$time';
$admin1=new Model('mytask');
$list=$admin1->query($sql);
第2个回答  2014-03-14
$sql='select * from think_mytask where strtotime(starttime)<=$time and="">=$time';
应该是这样吧

$sql='select * from think_mytask where strtotime(starttime)<=$time and strtotime(endtime
)>=$time';
相似回答