JS get the last day of the current month

<Button onclick = "function_name ()"> get the last day of the current month </ button>

<Script type = "text / JavaScript">
function FUNCTION_NAME (argument) {
var = new new DATE a Date ();
var date.getMonth the currentMonth = (); // Get month
var nextMonth = ++ currentMonth; // increment 1 Month [program] month is zero
var nextMonthFirstDay = new date (date.getFullYear ( ), nextMonth, 1); // get the current system time of the object based on the date and month of the year
var oneDay = 1000 * 60 * 60 * 24; // get day milliseconds
var lastTime = new date (nextMonthFirstDay- oneDay); // total number of milliseconds obtained by subtracting the number of milliseconds a day of the month in the date of the current year value
var month = parseInt (lastTime.getMonth () + 1); // get the month
var day = lastTime.getDate (); // number of days to give
IF (month The <10) {
month The = '0' + month The
}
IF (day <10) {
day = '0' + day
}
Alert (new new Date (date.getFullYear () + '- ' + month + '-' + day));
}
</script>

Guess you like

Origin www.cnblogs.com/yhm9/p/11267476.html
Recommended