PHP "first date of this week" returns last month

Performance

var_dump(new \DateTime('first day of this week')); 

Returns September 1

https://3v4l.org/GIPKR

Is this a mistake, and is there any workaround?

enter image description here

+5
source share
2 answers

Please try the code below:

 var_dump(new \DateTime('monday this week')); 
+1
source

Refer to this: Finding the first day of the week via php Also try this -

  <?php // var_dump(new \DateTime('first day of this week')); echo date("Ymd", strtotime('monday this week')), "<br/>\n"; echo date("Ymd", strtotime('sunday last week')), "<br/>\n"; ?> 
-1
source

Source: https://habr.com/ru/post/1257757/


All Articles