if ($starttime=="" and $endtime==""){
//查询从当天倒回30的数据,如果查询数据库两个时间可以直接引用 $starttime=date("Y-m-d", strtotime("-30 days", time()));//-30;从现在时间倒回30 $endtime=date("Y-m-d");}select * from services where DATE_FORMAT(laifangtime, '%Y-%m-%d') >= '$starttime' and DATE_FORMAT(laifangtime, '%Y-%m-%d') <= '$endtime'