|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77999 strtotime("first monday 2019-07") returns 2019-07-08 instead of 2019-07-01
Submitted: 2019-05-10 12:48 UTC Modified: 2021-04-06 19:06 UTC
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:1 (16.7%)
From: dhanuk05 at gmail dot com Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 7.2.18 OS: *
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: dhanuk05 at gmail dot com
New email:
PHP Version: OS:


 [2019-05-10 12:48 UTC] dhanuk05 at gmail dot com
When using PHP date function for finding the first Monday, Tuesday etc, if the particular day is first of that month , it will return very next result

For example,

date("Y-m-d", strtotime("first monday 2019-07"));
Actually first Monday of July 2019 is 2019-07-01, but when we run this code its returning result as 2019-07-08


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-10 13:10 UTC]
-Summary: Bug In Date function +Summary: strtotime("first monday 2019-07") returns 2019-07-08 instead of 2019-07-01 -Package: Testing related +Package: Date/time related
 [2019-05-10 13:10 UTC]
this is consistent with 
> echo date("Y-m-d", strtotime("first day",strtotime("2019-07-01")));
which outputs 2019-07-02

however `date -d 'first monday 2019-07-01` correctly outputs Mon 01 Jul - so I'm not sure if this is a bug
 [2019-05-10 16:46 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2019-05-10 16:46 UTC]
Assigning to Derick as he's the maintainer of the DateTime lib (as far as I know)
 [2019-06-14 11:52 UTC]
this might be a duplicate of bug #77941
 [2020-07-24 09:12 UTC]
-Operating System: Windows +Operating System: *
 [2020-07-24 09:12 UTC]
Apparently, prepositions matter here:

    date("Y-m-d", strtotime("first monday of 2019-07"))

gives the desired result.
 [2021-04-06 19:06 UTC]
-Status: Assigned +Status: Not a bug
 [2021-04-06 19:06 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This is expected. "2019-07" means "2029-07-01" and "first monday" means: move one Monday ahead, which is documented at
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 18:01:36 2024 UTC