note 98255 added to function.date

From: Date: Fri, 04 Jun 2010 09:37:49 +0000
Subject: note 98255 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-169882@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 78.158.20.177 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/98255 Del: integrated -- https://master.php.net/note/delete/98255/integrated Del: useless -- https://master.php.net/note/delete/98255/useless Del: bad code -- https://master.php.net/note/delete/98255/bad+code Del: spam -- https://master.php.net/note/delete/98255/spam Del: non-english -- https://master.php.net/note/delete/98255/non-english Del: in docs -- https://master.php.net/note/delete/98255/in+docs Del: other reasons-- https://master.php.net/note/delete/98255 Reject -- https://master.php.net/note/reject/98255 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169882) next »