PHP 获取本周、今日、本月的起始时间戳
当前周的开始时间(周一)
$begintime = mktime(0, 0, 0, date(‘m’), (date(‘d’) – (date(‘w’)>0 ? date(‘w’) : 7) + 1), date(‘Y’));
当前周的结束时间(周天)
$endtime = mktime(0, 0, 0, date(‘m’), (date(‘d’) – (date(‘w’)>0 ? date(‘w’) : 7) + 7), date(‘Y’));
//今日开始时间戳和结束时间戳
$beginToday=mktime(0, 0, 0, date(‘m’), date(‘d’), date(‘Y’));
$endToday=mktime(0, 0, 0, date(‘m’), date(‘d’)+1, date(‘Y’))-1;
//本月起始时间戳和结束时间戳
$beginThismonth=mktime(0, 0, 0, date(‘m’), 1, date(‘Y’));
$endThismonth=mktime(23, 59, 59, date(‘m’), date(‘t’), date(‘Y’))
date_default_timezone_set('PRC');
$last_week_first = strtotime(date(‘Y-m-01’, strtotime(‘-1 week’)));
$last_week_last = strtotime(date(‘Y-m-d’,$last_week_first).”+1 week -1 day”);$last_month_first = strtotime(date(‘Y-m-01’, strtotime(‘-1 month’)));
$last_month_last = strtotime(date(‘Y-m-d’,$last_month_first).”+1 month -1 day”);$last_half_first = strtotime(date(‘Y-06-01’, strtotime(‘-6 month’)));
$last_half_last = strtotime(date(‘Y-m-d’,$last_half_first).”+6 month -1 day”);$last_year_first = strtotime(date(‘Y-01-01’, strtotime(‘-1 year’)));
$last_year_last = strtotime(date(‘Y-m-d’,$last_year_first).”+12 month -1 day”)