note 105672 deleted from datetime.diff by danbrown
| From: | danbrown@php.net | Date: | Tue, 06 Sep 2011 16:43:51 +0000 |
| Subject: | note 105672 deleted from datetime.diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182984@lists.php.net to get a copy of this message | ||
Note Submitter: puertoagp at gmail dot com
----
<?php
/*Actually diff works correctly, but not as many people expect*/
$january = new DateTime('2008-01-01');
$february = new DateTime('2011-02-07');
$interval = $february->diff($january);
echo $interval->format('The difference is %y years %m month and %d days'), '<br
/>';
// Outputs: The difference is 3 years 1 month and 6 days
/*Echoig $interval->format('%d') will output 6 days, the number of days between 01 and
07, not the total number of days between the two dates*/
?>