1<?PHP2 /**3 * Return nearly 7 days, month, month data4 * Regardless of the day (display background data dedicated)5 */6 functionWeekmonthlastmonth ($search _date= ' Week ') {7 8 Switch($search _date)9 {Ten Case' Week '://nearly 7 days One $start _date=Date("Y-m-d",Strtotime("-7 Days"))); A $end _date=Date("Y-m-d",Strtotime("-1 Days"))); - Break; - Case' Month '://this month the $start _date=Date("y-m-01",Strtotime("-1 Days"))); - $end _date=Date("Y-m-d",Strtotime("-1 Days"))); - Break; - Case' Last_month '://last month + $search _time=Strtotime("-1 month")); - $start _date=Date("y-m-01",$search _time); + $end _date=Date(' y-m-d ',Strtotime("$start _date+1 month-1 Day ")); A Break; at } - return Array($start _date,$end _date); - } - - Echo Print_r(Weekmonthlastmonth (' Week '),true); - Echo Print_r(Weekmonthlastmonth (' month '),true); in Echo Print_r(Weekmonthlastmonth (' Last_month '),true);
PHP returns nearly 7 days this month last month date