Depending on what you mean by “how many months”, this could work.

[php]
$months = intval((strtotime($time2) – strtotime($time1)) / (60*60*24*30));
[/php]

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).

To calculate the number of months from today to some point back in time:

[php]
$months = intval((strtotime(date(‘Y-m-d’)) – strtotime($time1)) / (60*60*24*30));
[/php]

Random Posts

 

Comments are closed.