note 98255 deleted from function.date by derick

From: Date: Sun, 15 Aug 2010 18:35:59 +0000
Subject: note 98255 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171699@lists.php.net to get a copy of this message
Note Submitter: arturaz at gmail dot com ---- To find difference in months this will help you: <?php function diff_in_months($start_date, $end_date, $additional_months=1) { $start_year = date("Y", strtotime($start_date)); $start_month = date("n", strtotime($start_date)); $end_year = date("Y", strtotime($end_date)); $end_month = date("n", strtotime($end_date)); $diff_in_months = ($end_year - $start_year) * 12 - $start_month + $end_month + $additional_months; return $diff_in_months; } // Usage echo "Diff in months: " . diff_in_monhts("2008-07-05", "2009-03-14", 1); ?>

« previous php.notes (#171699) next »