From: Operating system: Linux/Windows PHP version: 5.3.9 Package: Date/time related Bug Type: Bug Bug description:DateInterval::format("%a") unknown or zero
Description: ------------ similiar to fixed (?) bug #49778 when \DateInterval is created in any other way than \DateTime::diff it fails when asked for number of days (%a) seen also on : PHP 5.3.2-1ubuntu4.11 with Suhosin-Patch (cli) (built: Dec 13 2011 18:45:32) there i get: diff:2 string:0 construct:0 PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:18:37) there i get the same as on windows 5.3.9 no changes made in config during test on windows, beside the timezone was set to Europe/Warsaw by function before code http://windows.php.net/downloads/releases/php-5.3.9-nts-Win32-VC9-x86.zip Test script: --------------- <?php $now = new \DateTime(); $before = new \DateTime('-2 days'); $intervalFromDiff = $before->diff($now); $intervalFromString= \DateInterval::createFromDateString("2 days"); $intervalFromConstruct= new \DateInterval("P2D"); echo "\n diff:".$intervalFromDiff->format("%a"); echo "\n string:".$intervalFromString->format("%a"); echo "\n construct:".$intervalFromConstruct->format("%a"); Expected result: ---------------- diff:2 string:2 construct:2 Actual result: -------------- diff:2 string:0 construct:(unknown) -- Edit bug report at https://bugs.php.net/bug.php?id=60774&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60774&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60774&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60774&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60774&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60774&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60774&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60774&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60774&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60774&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60774&r=support Expected behavior: https://bugs.php.net/fix.php?id=60774&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60774&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60774&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60774&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60774&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60774&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60774&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60774&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60774&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60774&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60774&r=mysqlcfg