|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73942 $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday
Submitted: 2017-01-16 01:37 UTC Modified: 2017-02-12 20:20 UTC
From: blindcan at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.0.14 OS: Ubuntu 16.04
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.
Block user comment
Status: Assign to:
Bug Type:
From: blindcan at gmail dot com
New email:
PHP Version: OS:


 [2017-01-16 01:37 UTC] blindcan at gmail dot com
As the summary says, $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday.

Running the script below on 7.0.14 and 7.0.8 yields 2017-01-02, which is a Monday.

However, running the same script on 7.0.5 yields 2017-01-13, a Friday. I expected a Friday.

Test script:

$date1 = "2017-01-08"; // this is a Sunday
$date = new \DateTime($date1);
$date->modify('Friday this week');
$dateFormat = $date->format('Y-m-d');
echo $dateFormat;

Expected result:
Currently, it displays a Monday date on 7.0.14. Testing on 7.0.8 also yields a Monday.

I expect to see a Friday date on both PHP 7.0.5, and 7.0.14.

Here's another link that tests for all php versions and other base days -


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-16 07:40 UTC]
-Status: Open +Status: Duplicate
 [2017-01-16 07:40 UTC]
Looks like a duplicate of bug #72719.
 [2017-02-12 20:20 UTC]
-Status: Duplicate +Status: Closed -Assigned To: +Assigned To: derick
 [2017-02-12 20:20 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 20:01:32 2024 UTC