时间

求各种时间

注意上一个月不能使用 strtotime("-1 month"),5 月 31 日他会算出 5 月 1 日

$starttime = mktime(date('H'), date('i'), date('s'), date('m') - 1, 1, date('Y'));

其他全部算法

function time_slot(){
	$time['today']['begin'] = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$time['today']['end'] = mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
	$time['tomorrow']['begin'] =  mktime(0,0,0,date('m'),date('d')-1,date('Y'));
	$time['tomorrow']['end'] =  mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
	$time['week']['begin'] = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
	$time['week']['end'] = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
	$time['lastweek']['begin'] = mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
	$time['lastweek']['end'] = mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
	$time['month']['begin'] = mktime(0,0,0,date('m'),1,date('Y'));
	$time['month']['end'] = mktime(23,59,59,date('m'),date('t'),date('Y'));
	$time['lastmonth']['begin'] = mktime(0, 0 , 0,date("m")-1,1,date("Y"));
	$time['lastmonth']['end'] = mktime(23,59,59,date("m") ,0,date("Y"));
	return $time;
}