|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-05-10 12:48 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 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 bugApparently, prepositions matter here: date("Y-m-d", strtotime("first monday of 2019-07")) gives the desired result.