note 124147 added to class.dateperiod
| From: | Joey@php.net | Date: | Tue, 27 Aug 2019 15:11:36 +0000 |
| Subject: | note 124147 added to class.dateperiod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212027@lists.php.net to get a copy of this message | ||
This class isn't always intuitive. End is exclusive. All you need to do to include it is to add
a second (the smallest amount).
Microseconds are ignored.
php -r '
/***/$p1d = new DateInterval("P1D");
/***/$b = (new DateTime())->setTime(0, 0, 0, 0);
/***/$a = (clone $b)->sub($p1d);
/***/$f = function(DateTime $b)use($a, $p1d):void {
/***//***/$p = new DatePeriod($a, $p1d, $b);
/***//***/$i = iterator_to_array($p);
/***//***/print_r([$i[0], end($i), $a, $b]);
/***/};
/***/$f($b);
/***/$f($b->setTime(0, 0, 0, 1));
/***/$f($b->setTime(0, 0, 1, 0));
'
It is a sign of the end times.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 89.197.178.10)
----
Manual Page -- http://php.net/manual/en/class.dateperiod.php
Edit -- https://master.php.net/note/edit/124147
Del: integrated -- https://master.php.net/note/delete/124147/integrated
Del: useless -- https://master.php.net/note/delete/124147/useless
Del: bad code -- https://master.php.net/note/delete/124147/bad+code
Del: spam -- https://master.php.net/note/delete/124147/spam
Del: non-english -- https://master.php.net/note/delete/124147/non-english
Del: in docs -- https://master.php.net/note/delete/124147/in+docs
Del: other reasons-- https://master.php.net/note/delete/124147
Reject -- https://master.php.net/note/reject/124147
Search -- https://master.php.net/manage/user-notes.php