<?php
/**
* 返回近7天,本月,上月数据
* 不计当天(展示后台数据专用)
*/
function weekMonthLastMonth($search_date = 'week') { switch($search_date)
{
case 'week' : // 近7天
$start_date = date ("Y-m-d", strtotime("-7 days"));
$end_date = date ("Y-m-d", strtotime("-1 days"));
break;
case 'month' : // 本月
$start_date = date ("Y-m-01", strtotime("-1 days"));
$end_date = date ("Y-m-d", strtotime("-1 days"));
break;
case '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"));
break;
}
return array($start_date, $end_date);
} echo print_r(weekMonthLastMonth('week'), true);
echo print_r(weekMonthLastMonth('month'), true);
echo print_r(weekMonthLastMonth('last_month'), true);
05-02 11:03