我想建立一个PHP函数,根据日期会给我计算下一个X周周开始/结束日期
目前这周(周一至周日)20/8/12至26/8/12
继周+ 1(周一至周日)27/8/12到12年2月9日
继周+ 2(周一至周日)12年3月9日以09/9/12
下周+ 3(mon-sun)
后续摹周+ 4(周一至周日)
继周+ 5(周一至周日)
我已经使用以下尝试过,但有什么清洁剂?
$week0_mon = date("Y-m-d", strtotime(date("Y").'W'.date('W')."1"));
$week0_sun = date("Y-m-d", strtotime(date("Y").'W'.date('W')."7"));
$week1_mon = date("Y-m-d", strtotime(date("Y-m-d", strtotime($week0_mon)) . " +1 week"));
$week1_sun = date("Y-m-d", strtotime(date("Y-m-d", strtotime($week0_sun)) . " +1 week"));
echo $week0_mon.' to '.$week0_sun.'<br />';
echo $week1_mon.' to '.$week1_sun.'<br />';
date('N',$ timestamp);会给你星期一数字星期一(1-7)。所以如果你strtotime(' - '。(date('N',$ timestamp)-1)。'days',$ timestamp);它会将时间戳移回星期一。 – Waygood