0

I found a possible bug in PHP date function, if you run this code:

date('Y-m-d', strtotime('first monday 2020-06'));

the output is 2020-06-08 instead of 2020-06-01, is this a bug or i'm doing something wrong?

2
  • 2
    php.net/manual/en/datetime.formats.relative.php - "first Monday" and "first Monday of" work differently Commented May 14, 2020 at 15:15
  • 4
    The first seven days of the month are not necessarily the first calender week of the month. Commented May 14, 2020 at 15:15

2 Answers 2

3

You need to put an "of" between first monday and the date date('Y-m-d', strtotime('first monday of 2020-06 ')); You can read about it at relative Formats

Sign up to request clarification or add additional context in comments.

1 Comment

I’m happy to help
1

You can write first monday of june 2020 in strtotime() like below :

echo date('Y-m-d', strtotime("first monday of june 2020"));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.