From: tj at systisoft dot com Operating system: All PHP version: 5.3CVS-2008-07-17 (CVS) PHP Bug Type: Feature/Change Request Bug description: DateInterval has a limitation of 4 chars for ISO durations
Description: ------------ If you want to create a DateInterval of 36000 seconds (10 hours) the creation will fail because you have a limit of 4 chars in the format accepted by the constructor. Up to days you can do the "carry over" calculation for yourself (But not for months or years), but if you get an offset in seconds from a source you cannot control it would be nice if you could just do: $date->add(new DateInterval('PT' . $seconds . 'S')); Now you have to check if seconds exceeds the limit an if it exceeds the limit you have to recalculate yourself. That is not nice from a user point of view. Reproduce code: --------------- $d = new DateTime('2008-01-01 10:00:00 UTC'); $d->add(new DateInterval('PT36000S')); echo $d->format(DATE_ISO8601), PHP_EOL; Expected result: ---------------- 2008-01-01T20:00:00+0000 Actual result: -------------- PHP Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (PT36000S)' in /Users/tobias/test.php:2 Stack trace: #0 /Users/tobias/test.php(2): DateInterval->__construct('PT36000S') #1 {main} thrown in /Users/tobias/test.php on line 2 Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (PT36000S)' in /Users/tobias/test.php:2 Stack trace: #0 /Users/tobias/test.php(2): DateInterval->__construct('PT36000S') #1 {main} thrown in /Users/tobias/test.php on line 2 -- Edit bug report at http://bugs.php.net/?id=45545&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45545&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45545&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45545&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45545&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45545&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45545&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45545&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45545&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45545&r=support Expected behavior: http://bugs.php.net/fix.php?id=45545&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45545&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45545&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45545&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45545&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45545&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45545&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45545&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45545&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45545&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45545&r=mysqlcfg