Get date for monday and friday for the current week (PHP)

后端 未结 8 1416
情话喂你
情话喂你 2020-12-01 03:46

How can I get the date for monday and friday for the current week?

I have the following code, but it fails if current day is sunday or saturday.

$cu         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 04:12

    Best solution would be:

    $monday = date( 'Y-m-d', strtotime( 'monday this week' ) );
    $friday = date( 'Y-m-d', strtotime( 'friday this week' ) );
    

提交回复
热议问题