PHP loop - add days to date -


I have the following code, though this works to add a date (between days) to a date (startup) Until I reach the end date, I will repeat it. How can i do this

  $ startDate = "2009-10-11"; $ EndDate = "2010-01-20"; Between $ days = 10; Function addDayswithdate ($ date, $ day) {$ date = strtotime ("+". $ Day. "Day", stratetime ($ date)); Return date ("Y-M-D", $ date); } $ Date = addDayswithdate ($ startDate, $ daysBetween);    

You can use the following function;

  & lt ;; Php $ startDate = "2009-10-11"; $ EndDate = "2010-01-20"; Between $ days = 10; $ FinalResult = array (); Function addDayswithdate ($ date, $ day, $ endDate, and $ last result) {$ tempDate = strtotime ($ date); $ TempDate + = 3600 * 24 * $ day; If ($ tempDate & lt; strtotime ($ endDate)) {$ finalResult [] = Date ("Y-M-D", $ tempDate); AddDayswithdate (date ("Y-M-D", $ tempDate), $ day, $ endDate, $ finalResult); } And {return true; }} AddDayswithdate ($ startDate, $ daysBetween, $ endDate, $ finalResult); var_dump ($ finalResult);   

Here is an active demo:

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

Simple file compression in C -

php - Sorting an multidimension array using usort fails -