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

thinkphp时间段查询解决方法

WBOY
Release: 2016-06-13 11:51:46
Original
999 people have browsed it

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 />
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template