[PHP] Months between two dates

2006-09-15 Thread Phillip Baker
Greetings Gents, I want to take two dates formatted as 11/1/1998 10/1/2008 And find out how many months have elapsed between them. I was wondering if there was a quick and dirty way to do this without a for loop. -- Blessed Be Phillip The House has passed a law that would abandon the

Re: [PHP] Months between two dates

2006-09-15 Thread Kyle
I will assume that your dates are stored in two variables $date1 and $date2 code $date1array = explode(/,$date1); $date2array = explode(/,$date2); // Assume Date 2 is later than Date 1 $months_apart = ($date2array[2] - $date1array[2])*12; // Month is later in date 1 than in date 2 // Find the

Re: [PHP] Months between two dates

2006-09-15 Thread Larry Garfield
Depending on what you mean by how many months, this could work too. $months = (strtotime($time2) - strtotime($time1)) / (60*60*24*30) That is, the number of seconds between those two dates divided by the number of seconds in a month (where month is normalized to 30 days). That may or may not