//今天开始
$beginToday = date('Y-m-d 00:00:00', time());
//今天结束
$endToday = date('Y-m-d 23:59:59', time());
//昨天开始
$beginYesterday = date('Y-m-d 00:00:00', strtotime(' -1 day'));
//昨天结束
$endYesterday = date('Y-m-d 23:59:59', strtotime(' -1 day'));
//本周开始,周一开始
$beginThisWeek = date('Y-m-d 00:00:00', strtotime('this week monday'));
//本周结束,周日结束
$endThisWeek = date('Y-m-d 23:59:59', strtotime('this week sunday'));
//上周开始,周一开始
$beginLastWeek = date('Y-m-d 00:00:00', strtotime('last week monday'));
//上周结束,周日结束
$endLastWeek = date('Y-m-d 23:59:59', strtotime('last week sunday'));
//本月开始
$beginThisMonth = date('Y-m-01 00:00:00');
//本月结束
$endThisMonth = date('Y-m-d 23:59:59', strtotime('Last day of this month'));
//上月开始
$beginLastMonth = date('Y-m-01 00:00:00', strtotime('last month'));
//上月结束
$endLastMonth = date('Y-m-d 23:59:59', strtotime('Last day of last month'));
//本季度开始
$beginThisSeason = date('Y-m-01 00:00:00', strtotime((1 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));
//本季度结束
$endThisSeason = date('Y-m-d 23:59:59', strtotime('last day of' . (3 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));
//上季度开始
$beginLastSeason = date('Y-m-01 00:00:00', strtotime((-2 - (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));
//上季度结束
$endLastSeason = date('Y-m-d 23:59:59', strtotime('last day of' . (- (date('n') % 3 == 0 ? 3 : date('n') % 3)) . ' month'));
//本年度开始
$beginThisYear = date('Y-01-01 00:00:00');
//本年度结束
$endThisYear = date('Y-12-31 23:59:59');
//上年度开始
$beginLastYear = date('Y-01-01 00:00:00', strtotime('last year'));
//上年度结束
$endLastYear = date('Y-12-31 23:59:59', strtotime('last year'));
评论