PHP获取“今天的时间戳”,再通过“今天”获取昨天和明天0点和23:59:59的时间戳
//设置中国时区
date_default_timezone_set('PRC');
//今天的时间搓
$today_start = strtotime(date('Y-m-d',time()).' 0:0:0');
$today_end = strtotime(date('Y-m-d',time()).' 23:59:59');
//昨天的时间戳
$yesterday_start = strtotime('-1 day'.' 0:0:0');
$yesterday_end = strtotime('-1 day'.' 23:59:59');
//查看上个月日期
$first_day_of_month = date('Y-m',time()).'-01 00:00:01';
$t = strtotime($first_day_of_month);
date('Y-m',$t);
date('Y-m',strtotime('- 1 month',$t));
date('Y-m',strtotime('- 2 month',$t));
//获取时间戳
//方法一:
$yesterday_s = mktime(0,0,0,date('m'),date('d')-1,date('Y'));//昨天开始的时间搓
$yesterday_e = mktime(23,59,59,date('m'),date('d')-1,date('Y'));//昨天结束的时间搓
$tenday_s = mktime(0,0,0,date('m'),date('d')-10,date('Y'));//10天前开始的时间戳
$tenday_e = mktime(23,59,59,date('m'),date('d')-10,date('Y'));//10天前结束的时间戳
//方法二:
$yesterday_s = strtotime(date("Y-m-d",strtotime("-10 day")).' 0:0:0'); //10天前开始的时间戳
$yesterday_e = strtotime(date("Y-m-d",strtotime("-10 day")).' 23:59:59');//10天前结束的时间戳
//方法三:
$day = $_REQUEST['day'];//需要统计的日期
$time_s = strtotime($day.' 0:0:0');
$time_e = strtotime($day.' 23:59:59');
//获取本周一的时间戳
strtotime(date("Y-m-d",strtotime("-1 week Monday")));
//获取今日开始时间戳和结束时间戳
$beginToday = mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday = mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//获取昨日起始时间戳和结束时间戳
$beginYesterday = mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday = mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//获取本周起始时间戳和结束时间戳
$beginThisweek = mktime(0,0,0,date('m'),date('d')-date('w')+1,date('y'));
$endThisweek = 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'));
//获取本月起始时间戳和结束时间戳
$beginThismonth = mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth = mktime(23,59,59,date('m'),date('t'),date('Y'));
//上个月的起始时间:
$begin_time = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month')));
$end_time = strtotime(date("Y-m-d 23:59:59", strtotime(-date('d').'day')));
$begin_year = strtotime(date("Y",time())."-1"."-1"); //本年开始
$end_year = strtotime(date("Y",time())."-12"."-31"); //本年结束
//现在的时间到第二天凌晨相差的时间戳
$time = (strtotime(date('Y-m-d'))+3600*24) - time() ;