Js gets the instance code for the last day of the month

  • 2020-03-29 23:51:14
  • OfStack

Here is the JS code:

@ the author YHC:


function getCurrentMonthLastDay(){ 
    var current=new Date(); 
    var currentMonth=current.getMonth(); 
    var nextMonth=++currentMonth; 

    var nextMonthDayOne =new Date(current.getFullYear(),nextMonth,1); 

    var minusDate=1000*60*60*24; 

    return new Date(nextMonthDayOne.getTime()-minusDate); 
  } 
  function getCurrentMonthLastDay(){
     var current=new Date();
     var currentMonth=current.getMonth();
     var nextMonth=++currentMonth;

     var nextMonthDayOne =new Date(current.getFullYear(),nextMonth,1);

     var minusDate=1000*60*60*24;

     return new Date(nextMonthDayOne.getTime()-minusDate);
    }


function getCurrentMonthFirstDay(){ 
    var current=new Date(); 
        current.setDate(1); 
    return current; 
   } 
 function getCurrentMonthFirstDay(){
     var current=new Date();
         current.setDate(1);
     return current;
    }


Related articles: