php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73633 fourth day {Month} {Year} returning fifth day
Submitted: 2016-12-01 13:54 UTC Modified: 2016-12-01 15:09 UTC
From: php at rcs dot us Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at rcs dot us
New email:
PHP Version: OS:

 

 [2016-12-01 13:54 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-01 14:19 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2016-12-01 14:19 UTC] 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 15:09 UTC] salathe@php.net
-Status: Verified +Status: Not a bug
 [2016-12-01 15:09 UTC] salathe@php.net
This is correct behaviour as already documented under the relative date formats section.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 01:01:30 2024 UTC