在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
if($filter['mode']) { switch ($filter['mode']) { case 1://今天的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0, date('m'),date('d'),date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date('m'),date('d'),date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 2://昨天的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0, date('m'),date('d'),date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date('m'),date('d'),date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 3://本周的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 4://上周的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+6,date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w"),date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 5://当月的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 6://上月的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m") -1,1,date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),0,date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 7://本季的数据 $season = ceil((date('n'))/3);//当月是第几季度 $time_start = date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))); $time_end = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 8://上季的数据 $season = ceil((date('n'))/3) - 1;//当月是第几季度 $time_start = date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))); $time_end = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 9://今年的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,1,1,date("Y"))); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,12,date('t'),date("Y"))); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; case 10://去年的数据 $time_start = date("Y-m-d H:i:s",mktime(0, 0 , 0,1,1,date("Y") -1)); $time_end = date("Y-m-d H:i:s",mktime(23,59,59,12,date('t'),date("Y") -1)); $ex_where .= ' and dt >= ' . strtotime($time_start) . ' and dt <= ' . strtotime($time_end); break; default://所有 break; } }
|
2022-08-17
2022-07-18
2022-11-06
2022-08-17
2022-07-30
请发表评论