Moment JS start and end of given month

前端 未结 11 1470
无人及你
无人及你 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 08:58

    your startDate is first-day-of-month, In this case we can use

    var endDate = moment(startDate).add(1, 'months').subtract(1, 'days');
    

    Hope this helps!!

提交回复
热议问题