php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72514 Behaviour of relative date format "this week" has changed
Submitted: 2016-06-29 10:00 UTC Modified: 2016-07-04 09:12 UTC
From: roelharbers at gmail dot com Assigned: ab
Status: Closed Package: Date/time related
PHP Version: 5.6.23 OS: Ubuntu, OSX
Private report: No CVE-ID:
 [2016-06-29 10:00 UTC] roelharbers at gmail dot com
Description:
------------
In php v5.6.22, the relative date format "this week" returns the next monday when called on a sunday date.

In php v5.6.23, it returns the previous monday.

It might be that the new behaviour is better, however, I find no mention of this backward compatibility breaking change in the changelog. 

Test script:
---------------
for v in 5.6.22 5.6.23; do ( echo $v: ; docker run --rm php:$v php -r 'date_default_timezone_set("UTC");echo (new DateTime("2016-06-19"))->modify("this week")->format("c")."\n";') done

Expected result:
----------------
I expect both versions to return the same.

Actual result:
--------------
5.6.22:
2016-06-20T12:00:00+00:00
5.6.23:
2016-06-13T12:00:00+00:00


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-29 11:36 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-06-29 11:36 UTC] cmb@php.net
Behavioral change confirmed: <https://3v4l.org/R4T5a>. Apparently,
`this week` is a shortcut for `Monday this week`, and the date
extension assumes monday to be the first day of the week.

Thus, the behavior before PHP 5.6.23 has to be regarded as a bug,
what has been reported as bug #63740, and recently been fixed[1].
Even though this commit added a NEWS entry, this did neither make
it into the PHP 5.6.23 NEWS[2] nor the Changelog[3] nor to the
NEWS/Changelog of later versions.

[1] <https://github.com/php/php-src/commit/f43f6fc3>
[2] <https://github.com/php/php-src/blob/php-5.6.23/NEWS>
[3] <http://php.net/ChangeLog-5.php#5.6.23>
 [2016-06-29 11:36 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2016-06-29 11:44 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339521
Log: Fix #72514: Behaviour of relative date format &quot;this week&quot; has changed
 [2016-06-29 11:47 UTC] cmb@php.net
-Assigned To: cmb +Assigned To: tyrael
 [2016-06-29 11:47 UTC] cmb@php.net
I've added a changelog entry to the "Relative Formats" section.
Ferenc, can you please add the missing NEWS and Changelog entries?
 [2016-07-03 22:44 UTC] tyrael@php.net
for the record the NEWS entry is there, but was added to the wrong php version (5.6.21), while in https://bugs.php.net/bug.php?id=63740 it was communicated as it will present in 5.6.22 (which did not happen as the commit was made after 5.6.22RC1 was tagged) while actually it was released in 5.6.23.
I've updated the NEWS in PHP-5.6 and the Changelog.
 [2016-07-03 22:55 UTC] cmb@php.net
-Assigned To: tyrael +Assigned To: ab
 [2016-07-03 22:55 UTC] cmb@php.net
Thanks, Ferenc. Antol, can you also please fix the NEWS and the
Changelog of PHP 7.0?
 [2016-07-04 09:12 UTC] ab@php.net
-Status: Verified +Status: Closed
 [2016-07-04 09:12 UTC] ab@php.net
Done. Thanks for the check, Christoph.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC