Get Start and End Days for a Given Week in PHP

前端 未结 16 1922
囚心锁ツ
囚心锁ツ 2020-12-01 03:49

I\'m trying to get the week range using Sunday as the start date, and a reference date, say $date, but I just can\'t seem to figure it out.

For example,

16条回答
  •  广开言路
    2020-12-01 04:16

    A simple code to return the days from start DateTime and end DateTime. Using gmdate() method you can format date/time.

    $start_str_date = strtotime($start_date);
    $end_str_date = strtotime($end_date);
    $interval_days = $end_str_date - $start_str_date;
    $days = gmdate('d',$interval_days);
    echo $days;
    

提交回复
热议问题