PHP: How to get Sunday and Saturday given a date input?

后端 未结 10 1817
终归单人心
终归单人心 2020-12-15 12:15

How can I get the Sunday and Saturday of the week given a specific date?

For example:

input: Monday, September 28, 2009

output should be:

10条回答
  •  误落风尘
    2020-12-15 12:28

    This is what your looking for. It is what I use.

    $beginningOfWeek = date('Y-m-d H:i:s', strtotime('last Sunday'));
    $endOfWeek = date('Y-m-d H:i:s', strtotime('+6 day', strtotime('last Sunday')) );
    

提交回复
热议问题