From: a dot schilder at gmx dot de Operating system: Windows7 PHP version: 5.5.4 Package: Date/time related Bug Type: Bug Bug description:DateTime('firstday') creates wrong result
Description: ------------ Following the documentation, creating a new DateTime instance with the realtive format "first day" (without month) should result in "the day of the first of the current month" (although it's recommended to use it with the optional month): http://php.net/manual/en/datetime.formats.relative.php In my tests (also in PHP 5.3.27 and PHP 5.4.7) a wrong date was created. As far as I can see, it's always the current time + 1 day. Test script: --------------- <?php echo PHP_VERSION . "\r\n"; $datetime1 = new DateTime('now'); echo $datetime1->format('Y-m-d H:i:s') . "\r\n"; $datetime2 = new DateTime('first day of this month'); echo $datetime2->format('Y-m-d H:i:s') . "\r\n"; $datetime3 = new DateTime('first day'); echo $datetime3->format('Y-m-d H:i:s') . "\r\n"; Expected result: ---------------- 2013-09-30: 5.5.4 2013-09-30 07:59:29 2013-09-01 07:59:29 2013-09-01 07:59:29 2013-10-01: 5.5.4 2013-10-01 07:59:29 2013-10-01 07:59:29 2013-10-01 07:59:29 2013-10-02: 5.5.4 2013-10-02 07:59:29 2013-10-01 07:59:29 2013-10-01 07:59:29 Actual result: -------------- 2013-09-30: 5.5.4 2013-09-30 07:59:29 2013-09-01 07:59:29 2013-10-01 07:59:29 2013-10-01: 5.5.4 2013-10-01 07:59:29 2013-10-01 07:59:29 2013-10-02 07:59:29 2013-10-02: 5.5.4 2013-10-02 07:59:29 2013-10-01 07:59:29 2013-10-03 07:59:29 -- Edit bug report at https://bugs.php.net/bug.php?id=65807&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65807&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65807&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65807&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65807&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65807&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65807&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65807&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65807&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65807&r=support Expected behavior: https://bugs.php.net/fix.php?id=65807&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65807&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65807&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65807&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65807&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65807&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65807&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65807&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65807&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65807&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65807&r=mysqlcfg