列举了计算常用时间的开始和结束时间戳的方法
function getTimeSE($type=''){
switch ($type){
case 'today'://今天
$result = array(
'start' => strtotime(date("Y-m-d")),
'end' => strtotime(date("Y-m-d")) + 86399,
);
break;
case 'preday'://昨天
$result = array(
'start' => strtotime(date("Y-m-d")) - 86400,
'end' => strtotime(date("Y-m-d")) - 1,
);
break;
case 'preweek'://上周
$result = array(
'start' => strtotime(date("Y-m-d", strtotime( - (date("w"))." day ", strtotime(" - 1 week")))),
'end' => strtotime( - (date("w"))." day ",strtotime(date("Y-m-d"))) - 1,
);
break;
case 'nowmon'://本月
$result = array(
'start' => strtotime(date("Y-m-01")),
'end' => strtotime(" + 1 month", strtotime(date("Y-m-01"))) - 1,
);
break;
case 'premon'://上月
$result = array(
'start' => strtotime(" - 1 month", strtotime(date("Y-m-01"))),
'end' => strtotime(date("Y-m-01")) - 1,
);
break;
case 'self'://自定义
$result = array(
'start' => strtotime($param['start']),
'end' => strtotime($param['end']),
);
break;
default://本周
$result = array(
'start' => strtotime( - (date("w"))." day ",strtotime(date("Y-m-d"))),
'end' => strtotime( +(7 - date("w"))." day ",strtotime(date("Y-m-d"))) - 1,
);
}
return $result;
}