function gettimestamp($targetTime){
switch ($targetTime){
case ‘today’://今天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘yesterday’://昨天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 day’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’));
break;
case ‘beforyesterday’://前天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-2 day’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 day’)));
break;
case ‘beforweek’://本周
$timeamp[‘start’]=strtotime(date(“Y-m-d H:i:s”,mktime(0, 0 , 0,date(“m”),date(“d”)-date(“w”)+1,date(“Y”))));
$timeamp[‘over’]=strtotime(date(“Y-m-d H:i:s”,mktime(23,59,59,date(“m”),date(“d”)-date(“w”)+7,date(“Y”))));
break;
case ‘nowmonth’://本月
$timeamp[‘start’]=strtotime(date(‘Y-m-01’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘permonth’://上月
$timeamp[‘start’]=strtotime(date(‘Y-m-01’,strtotime(‘-1 month’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-01’));
break;
case ‘preweek’://上周 注意我们是从周一开始算
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-2 week Monday’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 week Monday +1 day’)));
break;
case ‘nowweek’://本周
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 week Monday’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘preday’://30
$timeamp[‘start’]=strtotime(date(‘Y-m-d’),strtotime($param.’ day’));
$timeamp[‘end’]=strtotime(date(‘Y-m-d’));
break;
case ‘nextday’://30
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’),strtotime($param.’ day’));
break;
case ‘preyear’://去年
$timeamp[‘start’]=strtotime(date(‘Y-01-01’,strtotime(‘-1 year’)));
$timeamp[‘over’]=strtotime(date(‘Y-12-31’,strtotime(‘-1 year’)));
break;
case ‘nowyear’://今年
$timeamp[‘start’]=strtotime(date(‘Y-01-01’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘quarter’://季度
$quarter=ceil((date(‘m’))/3);
$timeamp[‘start’]=mktime(0, 0, 0,$quarter*3-2,1,date(‘Y’));
$timeamp[‘over’]=mktime(0, 0, 0,$quarter*3+1,1,date(‘Y’));
break;
default:
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
}
return $timeamp;
}
switch ($targetTime){
case ‘today’://今天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘yesterday’://昨天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 day’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’));
break;
case ‘beforyesterday’://前天
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-2 day’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 day’)));
break;
case ‘beforweek’://本周
$timeamp[‘start’]=strtotime(date(“Y-m-d H:i:s”,mktime(0, 0 , 0,date(“m”),date(“d”)-date(“w”)+1,date(“Y”))));
$timeamp[‘over’]=strtotime(date(“Y-m-d H:i:s”,mktime(23,59,59,date(“m”),date(“d”)-date(“w”)+7,date(“Y”))));
break;
case ‘nowmonth’://本月
$timeamp[‘start’]=strtotime(date(‘Y-m-01’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘permonth’://上月
$timeamp[‘start’]=strtotime(date(‘Y-m-01’,strtotime(‘-1 month’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-01’));
break;
case ‘preweek’://上周 注意我们是从周一开始算
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-2 week Monday’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 week Monday +1 day’)));
break;
case ‘nowweek’://本周
$timeamp[‘start’]=strtotime(date(‘Y-m-d’,strtotime(‘-1 week Monday’)));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘preday’://30
$timeamp[‘start’]=strtotime(date(‘Y-m-d’),strtotime($param.’ day’));
$timeamp[‘end’]=strtotime(date(‘Y-m-d’));
break;
case ‘nextday’://30
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’),strtotime($param.’ day’));
break;
case ‘preyear’://去年
$timeamp[‘start’]=strtotime(date(‘Y-01-01’,strtotime(‘-1 year’)));
$timeamp[‘over’]=strtotime(date(‘Y-12-31’,strtotime(‘-1 year’)));
break;
case ‘nowyear’://今年
$timeamp[‘start’]=strtotime(date(‘Y-01-01’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
case ‘quarter’://季度
$quarter=ceil((date(‘m’))/3);
$timeamp[‘start’]=mktime(0, 0, 0,$quarter*3-2,1,date(‘Y’));
$timeamp[‘over’]=mktime(0, 0, 0,$quarter*3+1,1,date(‘Y’));
break;
default:
$timeamp[‘start’]=strtotime(date(‘Y-m-d’));
$timeamp[‘over’]=strtotime(date(‘Y-m-d’,strtotime(‘+1 day’)));
break;
}
return $timeamp;
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。