Tried you code but it didn't seem to work for month - 1.....
This also seems to work:
$month = date("m", mktime(0,0,0,date("m")-1, date("01"), date("Y")));
$year = date("Y", mktime(0,0,0,date("m")-1, date("01"), date("Y")));
$from = $year . "-". $month . "-01 00:00:00";
As you can prob. see I have hard coded day to be 01 but that can easily be changed.
Haven't had time to test it out fully, this place is RAD to the max 🙂