Bug #77896 [NEW]: DateInterval::createFromDateString() no longer supports relative formats

From: Date: Mon, 15 Apr 2019 12:59:11 +0000
Subject: Bug #77896 [NEW]: DateInterval::createFromDateString() no longer supports relative formats
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220461@lists.php.net to get a copy of this message
From: renan-sub at protonmail dot com Operating system: PHP version: 7.3.4 Package: Date/time related Bug Type: Bug Bug description:DateInterval::createFromDateString() no longer supports relative formats Description: ------------ When calling DateInterval::createFromDateString() with "6 years and 4 months" as argument, it generates a warning. (See https://3v4l.org/sQjh2) Note: as a workaround (for the case mentioned) I'm using new \DateInterval('P6Y4M') Test script: --------------- <?php var_dump(\DateInterval::createFromDateString('6 years and 4 months')); Expected result: ---------------- object(DateInterval)#1 (16) { ["y"]=> int(6) ["m"]=> int(4) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } Actual result: -------------- Warning: DateInterval::createFromDateString(): Unknown or bad format (6 years and 4 months) at position 8 (a) -- Edit bug report at https://bugs.php.net/bug.php?id=77896&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77896&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77896&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77896&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77896&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77896&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77896&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77896&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77896&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77896&r=support Expected behavior: https://bugs.php.net/fix.php?id=77896&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77896&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77896&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77896&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77896&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77896&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77896&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77896&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77896&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77896&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77896&r=mysqlcfg

« previous php.bugs (#220461) next »