note 27156 deleted from ref.datetime by victor
| From: | victor@php.net | Date: | Mon, 09 Dec 2002 18:56:55 +0000 |
| Subject: | note 27156 deleted from ref.datetime by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40619@lists.php.net to get a copy of this message | ||
A quick snippet to get the number of months between two dates (only need the year and month):
// Get the number of months between the two dates
$count_month = $_POST['month_from']
$count_year = $_POST['year_from']
$months = 0;
while (($count_month != $_POST['month_to']) and ($count_year !=
$_POST['year_to'])) {
$count_month--;
if ($count_month == 0) {
$count_month = 12;
$count_year--;
}
$months++;
}
echo $months;
Obviously, the moneths must be in numerical format.
Allen