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都可以
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号