Bug #77999 [Asn->Nab]: strtotime("first monday 2019-07") returns 2019-07-08 instead of 2019-07-01

From: Date: Tue, 06 Apr 2021 19:06:49 +0000
Subject: Bug #77999 [Asn->Nab]: strtotime("first monday 2019-07") returns 2019-07-08 instead of 2019-07-01
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233243@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77999&edit=1

 ID:                 77999
 Updated by:         derick@php.net
 Reported by:        dhanuk05 at gmail dot com
 Summary:            strtotime("first monday 2019-07") returns 2019-07-08
                     instead of 2019-07-01
-Status:             Assigned
+Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
 Operating System:   *
 PHP Version:        7.2.18
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

This is expected. "2019-07" means "2029-07-01" and "first monday"
means: move one Monday ahead, which is documented at https://www.php.net/manual/en/datetime.formats.relative.php


Previous Comments:
------------------------------------------------------------------------
[2020-07-24 09:12:34] cmb@php.net

Apparently, prepositions matter here:

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

gives the desired result.

------------------------------------------------------------------------
[2019-06-14 11:52:02] sjon@php.net

this might be a duplicate of bug #77941

------------------------------------------------------------------------
[2019-05-10 16:46:23] girgias@php.net

Assigning to Derick as he's the maintainer of the DateTime lib (as far as I know)

------------------------------------------------------------------------
[2019-05-10 13:10:59] sjon@php.net

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 12:48:29] dhanuk05 at gmail dot com

Description:
------------
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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77999&edit=1


Thread (6 messages)

« previous php.bugs (#233243) next »