Another method ...
If you have a date , from this date you can find the start date and end date this week . But here the week number not used.
For instance:
You have date 2014-08-13 , then start date 2014-08-10 and end date 2014-08-08 are required .
Php code
$signupweek='2014-8-13'; for($i = 0; $i <7 ; $i++) { $date = date('Ym-d', strtotime("-".$i."days", strtotime($signupweek))); $dayName = date('D', strtotime($date)); if($dayName == "Sun") { echo "start day is ". $date."<br>"; } } for($i = 0; $i <7 ; $i++) { $date = date('Ym-d', strtotime("+".$i."days", strtotime($signupweek))); $dayName = date('D', strtotime($date)); if($dayName == "Sat") { echo "end day is ". $date."<br>"; } }
OUTPUT
start day is 2014-08-10 end day is 2014-08-16
Hope this is helpful.
source share