php - Want to add dates for week -


I am using this code in the code in one week :

  $ date1 = "2009-10-11"; $ D = new date time ($ 1 date); $ D- & gt; Modify ('+1 week'); Echo $ d- & gt; Format ('YMD'), "\ n";   

It works well, but this functionality is to be added:

  $ startDate = "2009-10-11"; $ EndDate = "2010-01-20";   

and want to create an array holding all +1 weeks between these dates. How can I do this?

Here's a way to do this:

  $ startDate = "2009-10-11"; $ EndDate = "2010-01-20"; $ Dates = array (); $ Temp = strtotime ($ startDate); Do {$ dates [] = Date ("Y-M-D", $ temp); $ Temp = strtotime ("+ 1 week", $ temp); } While ($ temp & lt; strtotime ($ endDate)); Print_r ($ DAYS);   

You can view

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 -