PHP获取本月开始、结束时间,近七天所有时间

//获取今天的时间戳
$today = time();
$month_first = strtotime(date("Y-m-01"));
$month_end = strtotime(date("Y-m-d",$month_first)."+1 month -1 day");

本周、下月,上月同理

获取近七天的日期

     //获取今天的时间戳 
        $today = strtotime('today');
        //七天前的日期
        $time_start = $today - 86400 * 6;
        //七天前的结束日期
        $time_end = $time_start + 86400;
        //获取近一周每天的日期
        for ($i = 0; $i < 7; $i++) {
            $jia = 86400 * $i;
            $dateArr[] = [
                'date_start' => date('Y-m-d', $time_start + $jia),
                'date_end' => date('Y-m-d',$time_end + $jia),
                'date_str_start' => $time_start + $jia,
                'date_str_end' => $time_end + $jia
            ];
        }
原文地址:https://www.cnblogs.com/T8888/p/12585881.html