-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|594|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Variables


 
HoboBen
Created : 26 November 2009
Edited : 27 November 2009
Language : Perl

PHP: daysBetween(date1, date2)



|edit| Fixed, hopefully! |edit|

function daysBetween($date1, $date2)

returns an array of dates containing every day between $date1 and $date2 in YYYYMMDD format.


 

Comments


Friday, 27 November 2009, 07:04
Jayenkai

Friday, 27 November 2009, 07:21
HoboBen
Haha, all right, that's quite simple!

But it's not what my code does - it actually returns a list of all the days between these two dates, which I needed for my website analytics code.

e.g.

Days Between 20080226 and 20080304

20080226
20080227
20080228
20080229
20080301
20080302
20080303
20080304
Friday, 27 November 2009, 07:37
Jayenkai
Oh, ok..
Don't forget, then, that date("Ymd",mktime(0,0,0,$day,$mon,$year)) can do "More/Less" days than in the actual month.
So (-10,9,2010) is the same as (22,8,2010)
quicker!