Get the first and last date of the previous month in JQuery

前端 未结 7 784
攒了一身酷
攒了一身酷 2021-02-09 07:41

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()+         


        
7条回答
  •  伪装坚强ぢ
    2021-02-09 08:02

        var firstDay = new Date();
        var secondDay = new Date();
        var thirdDay = new Date();
    
    
      //Now say you want to set secondDay as before 2 days
    
        secondDay.setDate(secondDay.getDate()-2);
    
    //Now say you want to set thirdDay as after 2 days  
    
            thirdDay.setDate(thirdDay.getDate()+2);
            alert("firstDay: "+firstDay+", secondDay:"+secondDay+", thirdDay:"+thirdDay);
            alert("date of thirdDay: dd/mm/yyyy  "+thirdDay.getDate()+"/"+ (thirdDay.getMonth()+1) +"/"+thirdDay.getFullYear()); 

提交回复
热议问题