I have fetched first and last day of the month in MomentJS like this:
我在MomentJS这个月的第一天和最后一天是这样的:
var startDate = ConvertToNewDateFormat(new Date(date.getFullYear(), date.getMonth(), 0));
var endDate = ConvertToNewDateFormat(new Date(date.getFullYear(), date.getMonth() + 1, 1));
This returns lets say:
这回来让我们说:
2016-05-01 -> start
2016-05-31 -> end
What I need is day before 05-01 and day after 31.05 (in general for every month like that), i.e. last day of previous month and first day of next month... How can I do this ??
我需要的是05-01之前的一天和31.05之后的一天(一般每个月都这样),即上个月的最后一天和下个月的第一天......我怎么能这样做?
1 个解决方案
#1
0
start=moment().startOf('month');
end=moment().endOf('month');
lastDayOfPrevMonth =moment(start).subtract(1,'day')
Check this fiddle
检查这个小提琴
#1
0
start=moment().startOf('month');
end=moment().endOf('month');
lastDayOfPrevMonth =moment(start).subtract(1,'day')
Check this fiddle
检查这个小提琴