LoginSignup
0
2

More than 5 years have passed since last update.

指定された日付の月曜日から次の月曜日までの日付を返す

Last updated at Posted at 2016-09-13
getThisWeek.php
    public function getThisWeek($day = null) {

        $day = !empty($day) ? strtotime($day) : strtotime(date('Y-m-d'));
        $monday = strtotime('this monday', $day);
        if ($day == $monday) {
            $from = date('Y-m-d', $monday);
            $to   = date('Y-m-d', strtotime('next monday', $monday));   
        } else {
            $from = date('Y-m-d', strtotime('last monday', $monday));
            $to   = date('Y-m-d', $monday); 
        }
        return array('from'=>$form, 'to'=>$to);
    }
0
2
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2