Aishwaryas Aishwaryas - 1 year ago 88
PHP Question

Find the week start and end dates of all weeks between two week numbers

I am trying to get the start date and end dates of all weeks between two week numbers.

That is one of my date is 2014-05-17 and its week number is 20 and other date is 2014-08-13 and its week number is 33.
My task is to get start and end dates of all weeks between 20 and 33. Here Sunday is the week start and Saturday week end.


//week number of current date.
$weekNumber = date("W");

Can anyone help to find the dates.

Answer Source

try this

$currentweek = date("W");

for($i=$signupweek;$i<=$currentweek;$i++) {
    echo "Week:".$i." Start date:".$result['start']." End date:".$result['end']."<br>";

function getWeek($week, $year) {
  $dto = new DateTime();
  $result['start'] = $dto->setISODate($year, $week, 0)->format('Y-m-d');
  $result['end'] = $dto->setISODate($year, $week, 6)->format('Y-m-d');
  return $result;


Week:20 Start date:2014-05-11 End date:2014-05-17
Week:21 Start date:2014-05-18 End date:2014-05-24
Week:22 Start date:2014-05-25 End date:2014-05-31
Week:23 Start date:2014-06-01 End date:2014-06-07
Week:24 Start date:2014-06-08 End date:2014-06-14
Week:25 Start date:2014-06-15 End date:2014-06-21
Week:26 Start date:2014-06-22 End date:2014-06-28
Week:27 Start date:2014-06-29 End date:2014-07-05
Week:28 Start date:2014-07-06 End date:2014-07-12
Week:29 Start date:2014-07-13 End date:2014-07-19
Week:30 Start date:2014-07-20 End date:2014-07-26
Week:31 Start date:2014-07-27 End date:2014-08-02
Week:32 Start date:2014-08-03 End date:2014-08-09
Week:33 Start date:2014-08-10 End date:2014-08-16
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download