正文 3996字数 375,179阅读

//今天开始 $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'));
Run code
Cut to clipboard


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