考虑一年中的一周(例如20)
如何检索本周的周一和周日?
我需要展示的是一个字符串,其中包含该周的日期范围,例如
from dayX of monthX of 2012 to dayY of monthXY of 2012
由于
答案 0 :(得分:1)
用strtotime()和date()播放一点......
<?php
$week_number = 20;
$year = 2012;
$monday = strtotime($year."W".str_pad($week_number,2,0,STR_PAD_LEFT)."1");
$sunday = strtotime($year."W".str_pad($week_number,2,0,STR_PAD_LEFT)."7");
echo "From " . date("l", $monday) . " " . date("j", $monday) . " of " . date("F", $monday) . " of " . $year . " to " . date("l", $sunday) . " " . date("j", $sunday) . " of " . date("F", $sunday) . " of " . $year;
?>
希望这有用......
答案 1 :(得分:0)
1月4日总是在第一周,所以一旦你知道星期几,你可以找到第一周的周一和周日。然后每隔一周再添加七天。