I am jealous of strtotime () in php, but I do mine in javascript using the moment. Not as sweet as from php, but the trick is also neat.
// first day of the month var firstDayThisMonth = moment(firstDayThisMonth).startOf('month').toDate();
Go back and forth with subtract() and add() with endOf() and startOf() :
// last day of previous month var yesterMonthLastDay = moment(yesterMonthLastDay).subtract(1,'months').endOf('month').toDate();
Rexford Jan 09 '16 at 20:43 2016-01-09 20:43
source share