Given a string like 2016-05-25
I want to get the first day of the previous month (e.x 2016-04-01
).
I have tried this
$month_ini = new DateTime("first day of last month");
$month_end = new DateTime("last day of last month");
but I get the first day of the previous month relative with the current month, which is not what I want.
Specifically I will get random dates from clients (with format 'Y-m-d') and I have to display the first day of the previous months relative with the client's requested month.