Toli Zaslavskiy Toli Zaslavskiy - 1 month ago 27
Javascript Question

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

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

ex:


  • Jan-Mar: 1st

  • Apr-Jul: 2nd

  • Jul-Sept: 3rd

  • Oct-Dec: 4th


Answer

This is now supported in moment. As easy as:

moment('2014-12-01').utc().quarter() //outputs 4
moment().quarter(); //outputs current quarter ie. 2