时间字段的格式是这样的 2012-10-22 17:00:00
我想读取最近1个小时新增的记录,$time_limit = 1 * 60 * 60;
然后查询:
select * from commentswhere timestamp > now() - $time_limit
不过没有反应啊,问题出在哪了呢
回复内容: 时间字段的格式是这样的 2012-10-22 17:00:00
我想读取最近1个小时新增的记录,$time_limit = 1 * 60 * 60;
然后查询:
select * from commentswhere timestamp > now() - $time_limit
不过没有反应啊,问题出在哪了呢
在字段上用函数会到帐索引失效, 你可以这样做
换个思路解决
$timedate = date('y-m-d h:i:s',time());$hourtime = date('y-m-d h:i:s',time()-3600);select * from comments where timestamp between $timedate and $timedate;
timestamp为啥不建int,却用datetime类型的。其实楼上可以少一个条件,当前时间不需要做限制的。