时间区间查询
1.先引⽤关于时间的js⽂件
(1)头部引⽤css⽂件
<link rel="stylesheet" type="text/css" href="/static/admin/css/jquery.datetimepicker.css"/>
(2)尾部引⽤js⽂件
<script src="/static/admin/js/jquery.js"></script>
<script src="/static/admin/js/jquery.datetimepicker.full.js"></script>
2.html内
<form action="{:url('admin/order/completed_order')}" method="post">
<input name="order_time" type="text" class="some_class" value="" id="some_class_1" />    <span >  ⾄  </span>
<input name="end_time" type="text" class="some_class" value="" id="some_class_2"/>    <button id="time" type="submit" >搜索</button>
</form>
</div>
3.js内
<script>
$('.some_class').datetimepicker();
</script>
4.php内
$number = input('order_number');    =>获取数据库字段
$data  = new OrderModel();      =>实例化
if($request->isPost()){
$ajax  = $request->param();      =>post获取提交的内容(⽇期)
$start = strtotime($ajax['order_time']);    =>开始时间
$end  = strtotime($ajax['end_time']);    =>结束时间
if(empty($start)){                =>开始时间为空
$start = '567968461';            =>定义开始⼀个时间范围
}   
if(empty($end)){                 =>结束时间为空
$end  = '6879402061';           =>定义结束⼀个时间范围
}
$time  = $data->find_time($start,$end);    =>按照获取的两个时间范围内进⾏搜索    $times = [];                    =>定义⼀个空数组
foreach ( $time as $val) {           =>⼆维⼀维数组
$times[] = $val['order_time'];
}
$str = join(',',$times);
$maps ="order_time in($str)";
js assignif(empty($times)){
$maps = $data->count_completed_order_select();  =>显⽰数据
$count = $data->count_completed_order($maps);    =>计算数据
$flag  = $data->completed_order($count,$maps);  =>分页
$this->assign('count', $count);
$this->assign('page', $flag->render());
$this->assign('data', $flag);
}
$count = $data->count_completed_order($maps);
$flag  = $data->completed_order($count,$maps);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。