日期按日、周、月 递增

时间:2021-12-25 14:29:05

// 日期按日、周、月 递增

 
public function completeChartData ( $data, $map )
    {
        if(empty($map['start_date']) || empty($map['end_date'])){
            return $data;
        }

        switch($map['dateline']){
            case 'WEEK':
                $diff_time = '+1 WEEK';
                break;
            case 'MONTH':
                $diff_time = '+1 MONTH';
                break;
            default:
                $diff_time = '+1 DAY';
        }

        $start_time = $map['start_date'];
        $end_time   = $map['end_date'];

        do {
            $xAxis[] = $start_time;
            $start_time = date ( 'Y-m-d', strtotime ( $diff_time, strtotime($start_time) ) );
        } while ( $start_time <= $end_time );
 
        dump($xAxis);
        exit;

    }