note 102874 rejected from dateperiod.construct by danbrown

From: Date: Fri, 11 Mar 2011 15:13:05 +0000
Subject: note 102874 rejected from dateperiod.construct by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177799@lists.php.net to get a copy of this message
Note Submitter: davidsteinsland at gmail dot com ---- 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?

« previous php.notes (#177799) next »