note 84738 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 26 Oct 2008 12:59:52 +0000 |
| Subject: | note 84738 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145769@lists.php.net to get a copy of this message | ||
Note Submitter: laszlo72 at gmail dot com
----
if you want to get the number of month
between two dates
you can use this function:
<?php
/*
$start = "YYYYMM" ;
$stop = "YYYYMM" ;
*/
function getNumMonth($start,$stop) {
$aSta = substr($start,0,4) ;
$aSto = substr($stop,0,4) ;
$mSta = substr($start,4,2) ;
$mSto = substr($stop,4,2) ;
if($aSta == $aSto) {
return $mSto-$mSta+1 ;
} else {
if(($aSto-$aSta) == 1) {
return 12-$mSta+$mSto+1 ;
} else {
return (12-$mSta+$mSto+1)+($aSto-$aSta-1)*12;
}
}
}
?>