Re: Months between two dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 be an acceptable normalization for what you're doing.  

Cheers.

On Friday 15 September 2006 01:16, Phillip Baker wrote:
> 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.

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux