PHP&;短时头痛

PHP&;短时头痛,php,strtotime,Php,Strtotime,这是我的函数 function thisProduction($week_start, $week_end, $this){ echo "<h2>Production > $this week (w/c ".$week_start." - ".$week_end.")</h2>"; } 我称之为意志论 thisProduction($this_week_start, $this_week_end, 'This'); thisProduction($last_wee

这是我的函数

function thisProduction($week_start, $week_end, $this){
echo "<h2>Production > $this week (w/c ".$week_start." - ".$week_end.")</h2>";
}
我称之为意志论

thisProduction($this_week_start, $this_week_end, 'This');
thisProduction($last_week_start, $last_week_end, 'Last');
我想要(以今天2017年1月31日为例)

昨天晚上这是'工作',但今天我得到这些结果

PRODUCTION > THIS WEEK (W/C 2017-02-06 - 2017-02-05)
PRODUCTION > LAST WEEK (W/C 2017-01-30 - 2017-01-29)

最好使用本周周一的

$this_week_start = date('Y-m-d',strtotime('monday this week'));
$this_week_end = date('Y-m-d',strtotime('sunday this week'));
$last_week_start = date('Y-m-d',strtotime('monday last week'));
$last_week_end = date('Y-m-d',strtotime('sunday last week'));
今天和昨天的结果:

生产>本周(w/c 2017-01-30-2017-02-05)


生产>上周(w/c 2017-01-23-2017-01-29)

更好地使用
本周的周一

$this_week_start = date('Y-m-d',strtotime('monday this week'));
$this_week_end = date('Y-m-d',strtotime('sunday this week'));
$last_week_start = date('Y-m-d',strtotime('monday last week'));
$last_week_end = date('Y-m-d',strtotime('sunday last week'));
今天和昨天的结果:

生产>本周(w/c 2017-01-30-2017-02-05)


生产>上周(w/c 2017-01-23-2017-01-29)

本周一
表示
即将到来的周一
,如果当天是
而不是周一
。因此,它工作正常。
本周一
意味着
即将到来的周一
,如果当天是
而不是周一
。所以它工作得很好。谢谢你的建议。我相信这也行。但我运行它,得到的日期与我的帖子中的日期相同。可能是服务器设置制作>本周(W/C 2017-02-06-2017-02-05)制作>上周(W/C 2017-01-30-2017-01-29)@Brad Sullivan检查
日期('Y-m-d')
给出
2017-01-31
。我测试过了,效果很好。本地和在线您的代码是完美的,再次感谢。我同意它在PHPTESTER上的效果和预期的一样,但是在我的主机上,我仍然得到与OP.Head相同的日期。谢谢你的建议。我相信这也行。但我运行它,得到的日期与我的帖子中的日期相同。可能是服务器设置制作>本周(W/C 2017-02-06-2017-02-05)制作>上周(W/C 2017-01-30-2017-01-29)@Brad Sullivan检查
日期('Y-m-d')
给出
2017-01-31
。我测试过了,效果很好。本地和在线您的代码是完美的,再次感谢。我同意它在PHPTESTER上的效果和预期的一样,但是在我的主机上,我仍然得到与OP.Head相同的日期。墙
$this_week_start = date('Y-m-d',strtotime('monday this week'));
$this_week_end = date('Y-m-d',strtotime('sunday this week'));
$last_week_start = date('Y-m-d',strtotime('monday last week'));
$last_week_end = date('Y-m-d',strtotime('sunday last week'));