Re: Months between two dates
| From: | Larry Garfield | Date: | Fri, 15 Sep 2006 14:22:12 +0000 |
| Subject: | Re: Months between two dates | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241824@lists.php.net to get a copy of this message | ||
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@garfieldtech.com 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