I have this script,
var today = new Date();
var dd = today.getDate();
var ffffd = today.getDate()-1;
var ffffdd = today.getDate()-2;
var mm = today.getMonth()+
What I have guessed is if current month is February then your output should be 1,31
because January's first day and last day is 1 and 31. So if that is the case then
var toDay = new Date();
var myDate = new Date(2016,toDay.getMonth()-1);
Fri Jan 01 2016 00:00:00 GMT+0530 (India Standard Time)
This will be assigned with the first day of the previous month.
Also, for the second case
var myDate = new Date(2016, toDay.getMonth());
myDate = new Date(myDate -1);
Sat Jan 31 2015 23:59:59 GMT+0530 (India Standard Time)
You can just use myDate
to find whatever you want.