This article mainly introduces how to get the sample code of the last day of the month for js. If you need it, you can refer to the following JavaScript code ::
@ Author YHC:
The Code is as follows:
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 );
}
The Code is as follows:
Function getCurrentMonthFirstDay (){
Var current = new Date ();
Current. setDate (1 );
Return current;
}
Function getCurrentMonthFirstDay (){
Var current = new Date ();
Current. setDate (1 );
Return current;
}