-4

Possible Duplicate:
Get Start and End Days for a Given Week in PHP

Example i use function date('W') will get week of the year. Suppose get week number 37. Can I get what days in this week Example 2011-09-12 to 2011-09-18

Thank you

Community
  • 1
  • 1
chenka
  • 77
  • 2
  • 3
  • 8

1 Answers1

0

You can use the DateTime and DatePeriod classes to work with dates and periods of time.

// ISO week to get the days of
$week = '2011W37';

// Date period for the days in the above week
$period = new DatePeriod(new DateTime($week), new DateInterval('P1D'), 6);

foreach ($period as $day) {
    echo $day->format('Y-m-d') . PHP_EOL;
}
salathe
  • 51,324
  • 12
  • 104
  • 132