note 102874 added to dateperiod.construct
| From: | davidsteinsland at gmail dot com | Date: | Fri, 11 Mar 2011 15:07:50 +0000 |
| Subject: | note 102874 added to dateperiod.construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177798@lists.php.net to get a copy of this message | ||
Be aware of the nature of this function:
If you set up two dates, like so:
2011-01-01 12:00:00
2011-01-02 12:00:00
and use the code:
<?php
$start_date = DateTime::createFromFormat ('Y-m-d H:i:s', '2011-01-01 12:00:00');
$end_date = DateTime::createFromFormat ('Y-m-d H:i:s', '2011-01-02 12:00:00');
$interval = new DatePeriod ($start_date, new DateInterval ('P1D'), $end_date);
?>
then $interval will contain only 1 date! Even though there is 24 hours between them.
If the end_date is specified at 12:00:01 instead, then you actually get 2 dates from DatePeriod.
Can someone tell if this is a bug, or just natural behaviour?
----
Server IP: 195.139.129.18
Probable Submitter: 79.161.170.5
----
Manual Page -- http://www.php.net/manual/en/dateperiod.construct.php
Edit -- https://master.php.net/note/edit/102874
Del: integrated -- https://master.php.net/note/delete/102874/integrated
Del: useless -- https://master.php.net/note/delete/102874/useless
Del: bad code -- https://master.php.net/note/delete/102874/bad+code
Del: spam -- https://master.php.net/note/delete/102874/spam
Del: non-english -- https://master.php.net/note/delete/102874/non-english
Del: in docs -- https://master.php.net/note/delete/102874/in+docs
Del: other reasons-- https://master.php.net/note/delete/102874
Reject -- https://master.php.net/note/reject/102874
Search -- https://master.php.net/manage/user-notes.php