note 125976 rejected from function.date-diff by Thiago
| From: | Thiago@php.net | Date: | Wed, 07 Apr 2021 05:59:00 +0000 |
| Subject: | note 125976 rejected from function.date-diff by Thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216256@lists.php.net to get a copy of this message | ||
Note Submitter: damien dot fa at gmail dot com
----
This behavior looks really weird to me :
// Just take a date, in Paris
$date = new DateTime('2021-04-01 01:30', new DateTimeZone('Europe/Paris'));
$dateLater = (clone $date);
$dateLater = $dateLater->add(new \DateInterval('P3M')); // add literally 3 months
â°
// ask the difference :
var_dump(date_diff($date, $dateLater)); // <= 2 months and 30 days ð¤¯
Why ? Why is it that if I add 3 months it becomes 2 months and 30 days (in the same timezone) ?