note 96646 deleted from datetime.diff by danbrown

From: Date: Tue, 09 Mar 2010 19:27:55 +0000
Subject: note 96646 deleted from datetime.diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166843@lists.php.net to get a copy of this message
Note Submitter: ocgdomains at gmail dot com ---- @andarin2 It's important to note that this class exists to smooth out some of the inconsistencies in the calendar itself. Months are not a fixed number of days, but range from 28 to 31 days, so going from 2-1-2009 to 3-1-2009 is one calendar month and people will call it as such. That's why you have this return 1 month for both of your examples. If you really want the number of seconds returned, use mktime() instead and simply subtract the smaller date from the larger one. <?php $diff=mktime(0,0,0,3,1,2009) - mktime(0,0,0,2,1,2009); //now $diff has the number of seconds between the two days $days=$diff/86400; //$days=28 ?> So we know that 28 days is the difference between the two dates but that doesn't help us if we need to know how many months that is

« previous php.notes (#166843) next »