There are many ways to do this, I give you two answers \ ideas:
1- Try using the strtotime
PHP function ( http://php.net/manual/es/function.strtotime.php )
Something like date("Y-m-d", strtotime("last day of this month"));
either the first day ... or any month.
2- Another way to use this:
First day:
date("Y-m-d", mktime(0, 0, 0, *YOUR MONTH PARAM*,1 ,date("Y")));
Last day:
date("Y-m-d", mktime(0, 0, 0, *YOUR MONTH PARAM*+1,0,date("Y")));
mktime :
http://php.net/manual/es/function.mktime.php
!