php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78000 Missing description of reltext's different behaviors (static & method on object)
Submitted: 2019-05-10 14:22 UTC Modified: 2019-05-10 16:49 UTC
From: ssimo3 at lsuhsc dot edu Assigned:
Status: Verified Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 - 29 = ?
Subscribe to this entry?

 
 [2019-05-10 14:22 UTC] ssimo3 at lsuhsc dot edu
Description:
------------
---
From manual page: https://php.net/datetime.formats.relative
---

What is missing is the following paragraph:

"The referent of the reltext keywords depend on the context in which the relative format string is used. If used with a static method or function, the referent is the current system timestamp. However, if used in DateTime::modify() or DateTimeImmutable::modify(), the referent is the object on which the modify() method is called."

Thank you! 

Test script:
---------------
<?php
header("Content-Type: text/plain");
$thisMonthDateTime = date_create("first day of this month");
echo $thisMonthDateTime->format("Y-m-d") . "\r\n";
$januaryDateTime = DateTime::createFromFormat("Y-m-d", "2019-01-15");
$januaryDateTime->modify("first day of this month");
echo $januaryDateTime->format("Y-m-d");

Actual result:
--------------
The two displayed dates are different, AS THEY SHOULD BE. What is missing is DOCUMENTATION of the behavior.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-10 16:49 UTC] girgias@php.net
-Summary: Description of reltext behavior +Summary: Missing description of reltext's different behaviors (static & method on object) -Status: Open +Status: Verified -Operating System: Windows 10 x64 +Operating System: -PHP Version: 7.3.5 +PHP Version: Irrelevant
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 16:01:28 2019 UTC