PHP & 时常头痛
PHP & strtotime headache
这是我的函数
function thisProduction($week_start, $week_end, $this){
echo "<h2>Production > $this week (w/c ".$week_start." - ".$week_end.")</h2>";
}
这是我定义参数的地方
$this_week_start = date('Y-m-d',strtotime('this Monday'));
$this_week_end = date('Y-m-d',strtotime('this Sunday'));
$last_week_start = date('Y-m-d',strtotime('last Monday'));
$last_week_end = date('Y-m-d',strtotime('last Sunday'));
我这样称呼遗嘱参数
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-01-30 - 2017-02-05)
Production > Last week (W/C 2017-01-23 - 2017-01-29)
昨晚这是 'working' 但今天我得到了这些结果
PRODUCTION > THIS WEEK (W/C 2017-02-06 - 2017-02-05)
PRODUCTION > LAST WEEK (W/C 2017-01-30 - 2017-01-29)
更好地使用monday this week
:
$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)
这是我的函数
function thisProduction($week_start, $week_end, $this){
echo "<h2>Production > $this week (w/c ".$week_start." - ".$week_end.")</h2>";
}
这是我定义参数的地方
$this_week_start = date('Y-m-d',strtotime('this Monday'));
$this_week_end = date('Y-m-d',strtotime('this Sunday'));
$last_week_start = date('Y-m-d',strtotime('last Monday'));
$last_week_end = date('Y-m-d',strtotime('last Sunday'));
我这样称呼遗嘱参数
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-01-30 - 2017-02-05)
Production > Last week (W/C 2017-01-23 - 2017-01-29)
昨晚这是 'working' 但今天我得到了这些结果
PRODUCTION > THIS WEEK (W/C 2017-02-06 - 2017-02-05)
PRODUCTION > LAST WEEK (W/C 2017-01-30 - 2017-01-29)
更好地使用monday this week
:
$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)