php strtotimeの取得時間は今月先月の今週の年度昨日......

15172 ワード

自分の基础がしっかりしていないせいで、、、、、、、、これらの时间を取得してぼんやりと多くの时間を使ってへへへ记录します
補充を歓迎します!~~~~~
class Time
{
    private $input_time;
    public function __construct($time)
    {
        $this->input_time=$time;
    }

    //    
    public  function  getYear(){
        $year=date('Y',$this->input_time);
        return[
            strtotime(date($year.'-01-01 00:00:00')) ,
            strtotime(date($year.'-12-31 23:59:59'))
        ];
    }

    //     
    public function getMonth(){
        $year=date('Y',$this->input_time);
        $month =date('m',$this->input_time);
        $endDay = date('t',$this->input_time);
        $Day = strtotime($year.'-'.$month.'-'.$endDay.' 23:59:59');
        return [
           strtotime(date($year.'-'.$month.'-1 00:00:00')),
           strtotime(date('Y-m-d H:i:s',$Day))
        ];
    }

    //    
    public  function getLastMonth(){
        $year=date('Y',$this->input_time);
        $month =date('m',$this->input_time);
        $day = date('d',$this->input_time);
        $res = $year.'-'.$month.'-'.$day;
        return[
            strtotime(date('Y-m'.'-1 00:00:00',strtotime("$res -1 month"))),
            strtotime(date('Y-m-t'.' 23:59:59',strtotime("$res -1 month")))
        ];
    }


    //    
    public  function  getWeek(){
        $year=date('Y',$this->input_time);
        $month =date('m',$this->input_time);
        $day = date('d',$this->input_time);
        $week = date('w',$this->input_time);
        return[
          strtotime(date($year.'-'.$month.'-'.($day-$week+1-7))),
          strtotime(date($year.'-'.$month.'-'.($day-$week+7-7)))

        ];
    }

    //    
    public  function  getYesterDay(){
        $year=date('Y',$this->input_time);
        $month =date('m',$this->input_time);
        $day = date('d',$this->input_time);
        return[
           strtotime(date($year.'-'.$month.'-'.($day-1).' 00:00:00')),
           strtotime(date($year.'-'.$month.'-'.($day-1).' 23:59:59'))
        ];

    }

}

どうやって呼び出すのでしょうか???
やはり自分に記録しておきましょう.
中には私のオプションの時間が伝わっています
$timeObj=new \app\Time(data['create_time']);
list($year_start,$year_end) = $timeObj->getYear();
は味噌で・・・簡単でしょう・・・うん.