PHP: Week starts on Monday, but “monday this week” on a Sunday gets Monday next week

后端 未结 10 1483
误落风尘
误落风尘 2020-12-09 14:43

Here\'s a summary of the issue: On Sundays, strtotime(\'this week\') returns the start of next week.

In PHP, the week seems to start on Monday. But, on

10条回答
  •  一整个雨季
    2020-12-09 15:34

    It's not ideal but this is what I resorted to using:

    if(date('N') == 7) { 
        $date = date('Y-m-d',strtotime('monday last week'));
    } else {
        $date = date('Y-m-d',strtotime('monday this week'));
    }
    

提交回复
热议问题