note 109661 added to dateperiod.construct
| From: | lars at hp-designs dot com | Date: | Tue, 07 Aug 2012 05:02:16 +0000 |
| Subject: | note 109661 added to dateperiod.construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189939@lists.php.net to get a copy of this message | ||
When you add the time 23:59:59 to the end DateTime object something like the following then the end
date will be included in the period:
$date_start = new DateTime('2012-03-12');
$date_end = new DateTime('2012-03-22 23:59:59');
$interval = '+2 days';
$date_interval = DateInterval::createFromDateString($interval);
$period = new DatePeriod($date_start, $date_interval, $date_end, DatePeriod::EXCLUDE_START_DATE);
foreach($period as $dt) {
echo $dt->format('d/m');
}
OUTPUT:
14/03
16/03
18/03
20/03
22/03
----
Server IP: 69.147.83.197
Probable Submitter: 101.103.149.112
----
Manual Page -- http://www.php.net/manual/en/dateperiod.construct.php
Edit -- https://master.php.net/note/edit/109661
Del: integrated -- https://master.php.net/note/delete/109661/integrated
Del: useless -- https://master.php.net/note/delete/109661/useless
Del: bad code -- https://master.php.net/note/delete/109661/bad+code
Del: spam -- https://master.php.net/note/delete/109661/spam
Del: non-english -- https://master.php.net/note/delete/109661/non-english
Del: in docs -- https://master.php.net/note/delete/109661/in+docs
Del: other reasons-- https://master.php.net/note/delete/109661
Reject -- https://master.php.net/note/reject/109661
Search -- https://master.php.net/manage/user-notes.php