Bug #73942 [Opn->Dup]: $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday

From: Date: Mon, 16 Jan 2017 07:40:30 +0000
Subject: Bug #73942 [Opn->Dup]: $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206655@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73942&edit=1 ID: 73942 Updated by: requinix@php.net Reported by: blindcan at gmail dot com Summary: $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday -Status: Open +Status: Duplicate Type: Bug Package: Date/time related Operating System: Ubuntu 16.04 PHP Version: 7.0.14 Block user comment: N Private report: N New Comment: Looks like a duplicate of bug #72719. Previous Comments: ------------------------------------------------------------------------ [2017-01-16 01:37:40] blindcan at gmail dot com Description: ------------ 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: --------------- <?php $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 - https://3v4l.org/ZuOhl ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73942&edit=1

« previous php.bugs (#206655) next »