Moment JS start and end of given month

前端 未结 11 1458
无人及你
无人及你 2020-11-28 08:19

I need to calculate a JS date given year=2014 and month=9 (September 2014).

I tried this:

var moment = require(\'moment\');
var startDate = moment( y         


        
11条回答
  •  死守一世寂寞
    2020-11-28 09:04

    Try the following code:

    const moment=require('moment');
    console.log("startDate=>",moment().startOf('month').format("YYYY-DD-MM"));
    console.log("endDate=>",moment().endOf('month').format("YYYY-DD-MM"));
    

提交回复
热议问题