PHP对请求时间范围条件的判断
當你展示列表,以時間作為條件查詢列表的時候,條件如下圖所示:
要記得對開始時間和結束時間進行判斷重寫,否則,哼哼,你試試就知道了
if (!empty($start_time) && empty($end_time)) {
$start_time = date('Y-m-d', strtotime(trim($start_time))) . ' 0:0:0';
$model = $model->where('ACCOUNT_RECHARGE.OrderTime', '>', $start_time);
}
if (!empty($end_time) && empty($start_time)) {
$end_time = date('Y-m-d', strtotime(trim($end_time))) . ' 23:59:59';
$model = $model->where('ACCOUNT_RECHARGE.OrderTime', '<', $end_time);
}
if (!empty($start_time) && !empty($end_time) && ($start_time <= $end_time)) {
$start_time = date('Y-m-d', strtotime(trim($start_time))) . ' 0:0:0';
$end_time = date('Y-m-d', strtotime(trim($end_time))) . ' 23:59:59';
$model = $model->whereBetween('ACCOUNT_RECHARGE.OrderTime', [$start_time, $end_time]);
}
這樣,就可以了。
?
轉載于:https://www.cnblogs.com/wyy-sunny/p/7387992.html
總結
以上是生活随笔為你收集整理的PHP对请求时间范围条件的判断的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图类算法总结
- 下一篇: jasper(二):制作饼状图和柱状图