Js gets a small example of the first and last day of the current month

  • 2020-03-29 23:47:51
  • OfStack

Introduce (link: http://arshaw.com/xdate/#Constructors) this small plug-in, do not know the baidu Google

The code is as follows:

var firstDate = new Date();
firstDate.setDate(1); //The first day
var endDate = new Date(firstDate);
alert("The first day : "+new XDate(firstDate).toString('yyyy-MM-dd')+"  Last day: "+new XDate(endDate).toString('yyyy-MM-dd'));


Well, try it yourself!

Related articles: