In Moment.js, how do you get the current financial Quarter?

后端 未结 9 1727
深忆病人
深忆病人 2020-12-14 16:07

Is there a simple/built in way of figuring out the current financial quarter?

ex:

  • Jan-Mar: 1st
  • Apr-Jul: 2nd
  • Jul-Sept: 3rd
9条回答
  •  别那么骄傲
    2020-12-14 17:04

    The simplist way to do this is

    Math.floor(moment.month() / 3)
    

    That will give you the zero based quarter index. ie 0, 1, 2, or 3.

    Then, if you want the quarter's literal number, just add one.

提交回复
热议问题