if($time=="今日"){ $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1; $begin = Date("Y-m-d",$beginToday); $end = Date("Y-m-d",$endToday); }else if($time=="昨日"){ $beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y')); $endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1; $begin = Date("Y-m-d",$beginYesterday); $end = Date("Y-m-d",$endYesterday); }else if($time=="上周"){ $beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')); $endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')); $begin = Date("Y-m-d",$beginLastweek); $end = Date("Y-m-d",$endLastweek); }else if($time=="本周"){ //判断当天是星期几,0表星期天,1表星期一,6表星期六 $w_day=date("w",time()); //php处理当前星期时间点上,根据当天是否为星期一区别对待 if($w_day=='1'){ $cflag = '+0'; $lflag = '-1'; }else { $cflag = '-1'; $lflag = '-2'; } //本周一零点的时间戳 $frist = strtotime(date('Y-m-d',strtotime("$cflag week Monday", time()))); $begin = Date("Y-m-d",$frist); $end = Date("Y-m-d",time()); }else if($time=="本月"){ $beginThismonth=mktime(0,0,0,date('m'),1,date('Y')); $endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y')); $begin = Date("Y-m-d",$beginThismonth); $end = Date("Y-m-d",$endThismonth); }else if($time=="上月"){ $beginLastmonth=mktime(0,0,0,date('m')-1,1,date('Y')); $endLastmonth=mktime(23,59,59,date('m')-1,date('t'),date('Y')); $begin = Date("Y-m-d",$beginLastmonth); $end = Date("Y-m-d",$endLastmonth); }else if($time=="最近三个月"){ $beginThreemonth=mktime(23,59,59,date('m'),date('t'),date('Y')); $endThreemonth=mktime(23,59,59,date('m')-3,date('t'),date('Y')); $begin = Date("Y-m-d",$beginThreemonth); $end = Date("Y-m-d",$endThreemonth); }else if($time=="本季"){ $begin = date('Y-m-d', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))); $end = date('Y-m-d', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))); }else if($time=="上季"){ $season = ceil((date('n'))/3);//当月是第几季度 $begin = date('Y-m-d', mktime(0, 0, 0,$season*3-3-3+1,1,date('Y'))); $end = date('Y-m-d', mktime(23,59,59,$season*3-3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y'))); }else if($time=="今年"){ $begin = date('Y',time()). '-' ."01-01"; $end = date('Y',time()). '-' ."12-31"; }else if($time=="去年"){ $d=strtotime('-1 years'); $begin = date('Y',$d)."-01-01"; $end = date('Y',$d)."-12-31"; }else if($time=="最近七天"){ $begin = date('Y-m-d', strtotime('-7 days')); $end = date('Y-m-d',time()); }else if($time=="最近三十天"){ $begin = date('Y-m-d', strtotime('-30 days')); $end = date('Y-m-d',time()); }