Bug #75849 [NEW]: Differente DateTime and strtotime with Relative Formats

From: Date: Fri, 19 Jan 2018 16:01:29 +0000
Subject: Bug #75849 [NEW]: Differente DateTime and strtotime with Relative Formats
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213621@lists.php.net to get a copy of this message
From: wandersonwhcr at gmail dot com Operating system: Debian GNU/Linux 9.3 (stretch) PHP version: 5.6.33 Package: Date/time related Bug Type: Bug Bug description:Differente DateTime and strtotime with Relative Formats Description: ------------ According to PHP Manual, DateTime class and strtotime functions use relative date and time formats. http://php.net/manual/en/datetime.formats.relative.php But using certain relative format in both classes, the result are not the same. Only PHP 5.6 generates the problem. With PHP >=7.0, the outputs are the same. Test script: --------------- <?php echo date('c') . PHP_EOL; // Current Date and Time $relative = 'first day of next month midnight -1 second'; echo date('c', (new DateTime($relative))->getTimestamp()) . PHP_EOL; echo date('c', strtotime($relative)) . PHP_EOL; ?> Expected result: ---------------- 2018-01-19T13:51:58-02:00 2018-01-31T23:59:59-02:00 2018-01-31T23:59:59-02:00 Actual result: -------------- 2018-01-19T13:51:58-02:00 2018-01-01T23:59:59-02:00 2018-01-31T23:59:59-02:00 -- Edit bug report at https://bugs.php.net/bug.php?id=75849&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75849&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75849&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75849&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75849&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75849&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75849&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75849&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75849&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75849&r=support Expected behavior: https://bugs.php.net/fix.php?id=75849&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75849&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75849&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75849&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75849&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75849&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75849&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75849&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75849&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75849&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75849&r=mysqlcfg

« previous php.bugs (#213621) next »