Bug #65807 [Opn]: DateTime('firstday') creates wrong result
| From: | salathe@php.net | Date: | Tue, 24 Dec 2013 16:57:05 +0000 |
| Subject: | Bug #65807 [Opn]: DateTime('firstday') creates wrong result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183458@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65807&edit=1
ID: 65807
Updated by: salathe@php.net
Reported by: a dot schilder at gmx dot de
Summary: DateTime('firstday') creates wrong result
Status: Open
Type: Bug
Package: Date/time related
Operating System: Windows7
PHP Version: 5.5.4
Block user comment: N
Private report: N
New Comment:
See bug #51096 [1], which introduced this change into 5.3.3.
[1] https://bugs.php.net/bug.php?id=51096
Previous Comments:
------------------------------------------------------------------------
[2013-12-23 23:28:24] Rican7 at gmail dot com
Hmm, it seems that this was broken sometime back in 5.3.3...
http://3v4l.org/Cioac
------------------------------------------------------------------------
[2013-10-02 08:15:20] a dot schilder at gmx dot de
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 this bug report at https://bugs.php.net/bug.php?id=65807&edit=1