Bug #70975 [NEW]: DatePeriod->interval:The DateInterval object has not been correctly initialized
From: marc at mabe dot berlin
Operating system:
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:DatePeriod->interval:The DateInterval object has not been correctly initialized
Description:
------------
If using the DatePeriod->interval the DateInterval object has not been
correctly initialized by its constructor.
With this bug it is impossible to take a DatePeriod object as one
argument in a function :(
Test script:
---------------
<?php
$start = new DateTime('2015-09-01');
$end = new DateTime('2015-09-02');
$interval = new DateInterval('P1D');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $current) {
$currentEnd = clone $current;
$currentEnd->add($period->interval);
var_dump($current, $currentEnd);
}
Expected result:
----------------
object(DateTime)#6 (3) {
["date"]=> string(26) "2015-09-01 00:00:00.000000"
["timezone_type"]=> int(3)
["timezone"]=> string(16) "Europe/Amsterdam"
}
object(DateTime)#7 (3) {
["date"]=> string(26) "2015-09-02 00:00:00.000000"
["timezone_type"]=> int(3)
["timezone"]=> string(16) "Europe/Amsterdam"
}
Actual result:
--------------
Warning: DateTime::add(): The DateInterval object has not been correctly
initialized by its constructor in /in/tmZN9 on line 10
object(DateTime)#6 (3) {
["date"]=> string(26) "2015-09-01 00:00:00.000000"
["timezone_type"]=> int(3)
["timezone"]=> string(16) "Europe/Amsterdam"
}
object(DateTime)#7 (3) {
["date"]=> string(26) "2015-09-01 00:00:00.000000"
["timezone_type"]=> int(3)
["timezone"]=> string(16) "Europe/Amsterdam"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=70975&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70975&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70975&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70975&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70975&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70975&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70975&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70975&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70975&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70975&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70975&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70975&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70975&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70975&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70975&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70975&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70975&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70975&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70975&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70975&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70975&r=mysqlcfg
Thread (5 messages)
- marc at mabe dot berlin