【问题标题】:moment js how to pass quarter number时刻js如何传递季度数
【发布时间】:2018-06-27 05:58:40
【问题描述】:

我正在使用 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 季度的开始和结束日期。

在上面的代码中如何传递季度数字。

请帮助我。

【问题讨论】:

    标签: javascript jquery momentjs


    【解决方案1】:

    给你。

    您当前的代码是:

    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>

    点击此处了解更多信息:https://momentjs.com/docs/#/get-set/quarter/

    【讨论】:

      猜你喜欢
      • 2013-12-19
      • 1970-01-01
      • 2019-07-10
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多