我正在使用moment.js。我正在使用以下代码
moment().startOf('quarter').format('MM-DD-YYYY'), moment().endOf('quarter').format('MM-DD-YYYY')
它返回April 1, 2018 - June 30, 2018
它返回当前季度日期。
我想获取第1,2,3,4季度的开始和结束日期。
在上面的代码中如何传递四分之一数字。
请帮助我。
答案 0 :(得分:5)
您在这里。
您当前的代码是:
moment().startOf('quarter')....
将此更改为:
moment().quarter(3).startOf('quarter')...
//在这里通过了第三季度
检查以下工作代码:
console.log(moment().quarter(3).startOf('quarter').format('MM-DD-YYYY'), moment().quarter(3).endOf('quarter').format('MM-DD-YYYY'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js"></script>