可能重复:
在PHP 中获取给定一周的开始和结束日期
例如,我使用函数date('W'(将得到一年中的星期。假设得到第37周。我能得到这周的几天吗示例2011-09-12到2011-09-18
感谢
您可以使用DateTime
和DatePeriod
类来处理日期和时间段。
// 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;
}