thinkphp时间段查询,比如查询2014-03-16 09:15:20到2014-04-16 09:15:20这个时间段内的数据
大神门来帮帮忙呀
假设你数据库存储时间的字段叫 time 格式是int 存储的是时间戳
可以这样查询
$t1 = 2014-03-16 09:15:20;$t2 = 2014-04-16 09:15:20;$timestart = strtotime($t1);$timeend = strtotime($t2);$model = M("你的数据表")$res = $model -> where("time >= $timestart and time <= $timeend ")->select();
假设你数据库存储时间的字段叫 time 格式是int 存储的是时间戳
可以这样查询
$t1 = 2014-03-16 09:15:20;$t2 = 2014-04-16 09:15:20;$timestart = strtotime($t1);$timeend = strtotime($t2);$model = M("你的数据表")$res = $model -> where("time >= $timestart and time <= $timeend ")->select();
datetime也支持大于小于,至少mysql和sql server都可以