In a script that contains
date(\'Y-m-d\', strtotime(\'first day of last month\'))
in version 5.3.10 (localhost) I get, for example, \'2012
date('Y-m-d', strtotime('first day of -1 month'))
Works fine on PHP 7.0
As simple as:
date('Y-m-01')
The first day of any month always is 1.
That's a known bug from PHP 5.2.17
You should use the mktime() function:
<?php
echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y'))); //2012-03-01
?>
See In Action