Doc #73633 [Ver->Nab]: fourth day {Month} {Year} returning fifth day

From: Date: Thu, 01 Dec 2016 15:09:40 +0000
Subject: Doc #73633 [Ver->Nab]: fourth day {Month} {Year} returning fifth day
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14167@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73633&edit=1 ID: 73633 Updated by: salathe@php.net Reported by: php at rcs dot us Summary: fourth day {Month} {Year} returning fifth day -Status: Verified +Status: Not a bug Type: Documentation Problem Package: Date/time related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: This is correct behaviour as already documented under the relative date formats section. Previous Comments: ------------------------------------------------------------------------ [2016-12-01 14:19:18] cmb@php.net To get the first day of the month you have to use first day of July 2016 (note the "of"). fourth day is identical to 4 days which is identical to +4 days, so fourth day of July 2016 is identical to July 2014 +4 days, see <https://3v4l.org/pSsLn>. Thus, the behavior is expected, but the documentation could be improved. ------------------------------------------------------------------------ [2016-12-01 13:54:58] php at rcs dot us Description: ------------ --- From manual page: http://www.php.net/datetime.formats.relative --- While no specific example on this is in the manual, "fourth day July 2016" returns July 5th. It's not specific to the fourth, any day is returning plus one. Test script: --------------- $firstDayJuly2016 = new DateTime("first day July 2016"); // The following returns // object(DateTime) // public 'date' => string '2016-07-02 00:00:00' (length=19) var_dump($firstDayJuly2016); $fourthDayJuly2016 = new DateTime("fourth day July 2016"); // The following returns // object(DateTime) // public 'date' => string '2016-07-05 00:00:00' (length=19) var_dump($fourthDayJuly2016); die; Expected result: ---------------- I believe the expectation is that the "fourth day July 2016" would return July 2016-07-04. Actual result: -------------- "fourth day July 2016" returns July 2016-07-05. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73633&edit=1

« previous php.doc.bugs (#14167) next »