Home > Web Front-end > JS Tutorial > js gets the last day of the month example code_javascript skills

js gets the last day of the month example code_javascript skills

WBOY
Release: 2016-05-16 17:14:06
Original
1194 people have browsed it

The following is the JS code::

@ author YHC:

Copy code 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);
}

Copy code 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;
}
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template