Robert Trzebiński
Robert Trzebiński

Reputation: 1357

'first monday previous month' strtotime confusion

Today is 2015-05-14

Why does

date('Y-m-d', strtotime('first monday previous month'))

return

string(10) "2015-04-18"

I expected this to return 2015-04-06 - first Monday of previous month.

Upvotes: 1

Views: 128

Answers (2)

user3419778
user3419778

Reputation: 866

Please try with this..

echo date('Y-m-d', strtotime('First Monday of ' . date("Y-m-d", strtotime("-1 months") ) ));

Upvotes: 0

Sougata Bose
Sougata Bose

Reputation: 31749

Missing of in the datetime string. Try with -

date('Y-m-d', strtotime('first monday of previous month'));

Docs

Upvotes: 2

Related Questions