Finding start date of the each week php -


Suppose there are 10 weeks; Week_1st, week_2, week_3th ..., week_10th 2014-05-01 00:00:00 starts at 10-10, how can I get the start date of the week (last week)? Will you show me in php? Thanks a lot.

If you want to go exactly 5 weeks ago (or something else), then try: $ date = new date time ('2014-05-01'); $ Date-> Modify ('- 5 weeks'); Transcript $ date- & gt; Format ('Y-M-D');

If you always want to receive Monday (or similar), you can try it

  $ date = new dateTime ('2014-05- 01 '); $ Day = (int) $ date- & gt; Format ('w'); $ Date-> Modify ('- 5 weeks'); $ Date-> Modify (1 - $ day. 'Days'); // 1 = echo on Monday $ date- & gt; Format ('Y-M-D');    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -