Best way to...
| From: | Boget, Chris | Date: | Tue, 24 Jul 2001 18:00:37 +0000 |
| Subject: | Best way to... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-59387@lists.php.net to get a copy of this message | ||
get the difference in months between two dates
using a unix time stamp?
I know I can do something like this:
$startMonth = date( "m", $startTimestamp );
$startYear = date( "Y", $startTimestamp );
$endMonth = date( "m", $endTimestamp );
$endYear = date( "Y", $endTimestamp );
$numMonths = $endMonth - $startMonth;
if( $startMonth > $endMonth ) {
$numMonths += 12;
}
$numMonths += ( 12 + ( $endMonth - $startMonth ));
Is there some better way?
Chris