|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80409 DateTime::modify() loses time with 'weekday' parameter
Submitted: 2020-11-24 10:05 UTC Modified: 2022-05-13 13:36 UTC
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: karol dot piotr dot kolanko at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.4.12 OS: Linux
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: karol dot piotr dot kolanko at gmail dot com
New email:
PHP Version: OS:


 [2020-11-24 10:05 UTC] karol dot piotr dot kolanko at gmail dot com
DateTime::modify() with parametrem 'weekday' loses time value.

Also date() function.

Test script:
$date = '2020-11-27 12:33:00';

echo date('Y-m-d H:i:s', strtotime($date.' +1 day')); 
// Correct: 2020-11-28 12:33:00
echo date('Y-m-d H:i:s', strtotime($date.' +1 Weekday'));
// Uncorrect, lost time: 2020-11-30 00:00:00

$date1 = new DateTime($date);
$date2 = new DateTime($date);

$date2->modify('+1 day');
echo $date2->format('Y-m-d H:i:s');
// Correct: 2020-11-28 12:33:00
$date1->modify('+1 weekday');
echo $date1->format('Y-m-d H:i:s');
// Uncorrect, lost time: 2020-11-30 00:00:00


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-24 14:20 UTC]
For reference: <>

According to the manual this is supposed to work[1], but I have no
idea what "+1 weekday" is supposed to do.

[1] <>
 [2020-11-24 16:11 UTC]
-Status: Open +Status: Verified
 [2020-11-24 16:11 UTC]
I just learned that "weekday" refers to Mon to Fri, so yes, this
looks like a bug.
 [2021-01-02 01:13 UTC] simapple at qq dot com
i think that code means get a datetime after a weekend .
 "+1 weekday"  works to get next weekday.
i think add syntax "+1 weekend" is better than change "+1 weekday".
 [2022-05-13 13:36 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: derick
 [2022-05-13 13:36 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

This was fixed in 8.0.10 already:
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Sep 28 06:05:53 2022 UTC