note 22540 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:50:07 +0000
Subject: note 22540 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58258@lists.php.net to get a copy of this message
Note Submitter: dan at mojavelinux dot com ---- Here is month diff just like mysql does...it is called period_diff /** * Function will determine number of months between two dates * * This is the same implementation as the mysql function PERIOD_DIFF and * will work with the awkward month period to determine the number * of months between two dates. * * @param int initial timestamp * @param int final timestamp * * @access public * @return int months difference between two dates */ function period_diff($in_dateLow, $in_dateHigh) { // swap dates if they are backwards if ($in_dateLow > $in_dateHigh) { $tmp = $in_dateLow; $in_dateLow = $in_dateHigh; $in_dateHigh = $tmp; } $dateLow = $in_dateLow; $dateHigh = strftime('%m/%Y', $in_dateHigh); $periodDiff = 0; while (strftime('%m/%Y', $dateLow) != $dateHigh) { $periodDiff++; $dateLow = strtotime('+1 month', $dateLow); } return $periodDiff; }

« previous php.notes (#58258) next »