How to get a month before a date

//Date, jquery gets the month before the current date 
 var latayesr = new Date().getFullYear()-1;
 var currentYear = new Date().getFullYear();
 var currentMonth = new Date().getMonth();
 var date = currentYear+'-'+currentMonth;
 if(currentMonth == 0){
        currentYear = currentYear-1;
        date =currentYear +'-'+12;
 }
 //Date, jquery gets the end of the month before the current date


// Assign a value to the date box
 $("#date1").scroller('setDate',new Date(date),true); /*Assign a value to the date input box, the value is one month before the current date*/
 $("#date2 ").scroller('setDate',new Date(latayesr+''),true); /*Assign the second date input box, the value is the year before the current year*/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324624388&siteId=291194637