Home  >  Article  >  Web Front-end  >  js small example of getting the first and last day of the current month_javascript skills

js small example of getting the first and last day of the current month_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:14:301016browse

Introducing XDate.JS this small plug-in, if you don’t know it, please search it on Baidu and Google

The code is as follows:

Copy codeThe code is as follows:

var firstDate = new Date( );

firstDate.setDate(1); //First day

var endDate = new Date(firstDate);

endDate.setMonth(firstDate.getMonth() 1);

endDate.setDate(0);

alert("First day: " new XDate(firstDate).toString('yyyy-MM-dd') " Last day: " new XDate(endDate).toString('yyyy-MM-dd'));


Okay, try it yourself!

Statement:
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