What days contain in this week [duplicate]
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
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;
}
精彩评论