Home >Backend Development >PHP Tutorial >thinkphp时间段查询解决方法

thinkphp时间段查询解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:51:461028browse

thinkphp时间段查询
thinkphp时间段查询,比如查询2014-03-16 09:15:20到2014-04-16 09:15:20这个时间段内的数据
------解决方案--------------------
不会,帮顶,哈哈
------解决方案--------------------
假设你数据库存储时间的字段叫 time 格式是int 存储的是时间戳
可以这样查询

<br />$t1 = 2014-03-16 09:15:20;<br />$t2 = 2014-04-16 09:15:20;<br />$timestart = strtotime($t1);<br />$timeend = strtotime($t2);<br />$model = M("你的数据表")<br />$res = $model -> where("time >= $timestart  and time <= $timeend ")->select();<br />


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn