This article mainly introduces the way PHP gets the first and last day of the week, and the friends you need can refer to the following
The first and last day of the week code is as follows: $date =new DateTime (); $date->modify (' This week '); $first _day_of_week= $date->format (' y-m-d '); $date->modify (' This week +6 days '); $end _day_of_week= $date->format (' Y-m-d '); tested modity did not know what to do, in the time to find another two examples code as follows://This week's Monday //@ $timestamp, a certain time stamp of a week, the default is the current time & nbsp @is_return_timestamp, whether to return a timestamp, otherwise return time format function this_monday ($timestamp =0, $is _return_timestamp=true) { static $cache; $id = $timestamp. $is _return_timestamp; if (!isset ($cache [$id]) { if (!$ Timestamp) $timestamp = time (); $monday _date = Date (' y-m-d ', $timestamp -86400*date (' W ', $timestamp) + (' W ', $ Timestamp) >0?86400:-/*6*86400*/518400); if ($is _return_timestamp) { $cache [$id] = Strtotime ($monday _ Date); }else{ $cache [$id] = $monday _date; } } return $cache [$id]; } //This The Sunday code for the week is as follows://@ $timestamp, a time stamp for a week, the default is the current time //@is_retUrn_timestamp, whether to return timestamp, otherwise return time format function this_sunday ($timestamp =0, $is _return_timestamp=true) { static $ Cache; $id = $timestamp. $is _return_timestamp; if (!isset ($cache [$id]) { if (! $timestamp) $timestamp = Time (); $sunday = This_monday ($timestamp) +/*6*86400*/518400; if ($is _return_timestamp) { $cache [$id ] = $sunday; }else{ $cache [$id] = date (' y-m-d ', $sunday); } } return $cache [$id]; }&NB Sp