note 84738 added to function.date
| From: | laszlo72 at gmail dot com | Date: | Mon, 28 Jul 2008 10:16:17 +0000 |
| Subject: | note 84738 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142842@lists.php.net to get a copy of this message | ||
if you want to get the number of month
between two dates
you can use this function:
/*
$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;
}
}
}
----
Server IP: 213.92.11.19
Probable Submitter: 89.97.199.172
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/84738
Del: integrated -- https://master.php.net/note/delete/84738/integrated
Del: useless -- https://master.php.net/note/delete/84738/useless
Del: bad code -- https://master.php.net/note/delete/84738/bad+code
Del: spam -- https://master.php.net/note/delete/84738/spam
Del: non-english -- https://master.php.net/note/delete/84738/non-english
Del: in docs -- https://master.php.net/note/delete/84738/in+docs
Del: other reasons-- https://master.php.net/note/delete/84738
Reject -- https://master.php.net/note/reject/84738
Search -- https://master.php.net/manage/user-notes.php