Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:14:30
Original
1042 people have browsed it

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!

Related labels:
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