Home >Web Front-end >JS Tutorial >js small example of getting the first and last day of the current month_javascript skills
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:
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!