Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 644
Toli Avatar asked Dec 26 '12 21:12

Toli


People also ask

How do you get a quarter in a moment?

1+ you can do something like the following: moment(). quarter() returns the current quarter number: 1, 2, 3, 4. moment().

How do you find the beginning of the month in a moment?

Use the Moment. We call moment to create a Moment object with the current date and time. Then we call clone to clone that object. Then we call startOf with 'month' to return the first day of the current month. And then we call format to format the date into the human-readable YYYY-MM-DD format.

What is Moment () in JavaScript?

Moment JS allows displaying of date as per localization and in human readable format. You can use MomentJS inside a browser using the script method. It is also available with Node. js and can be installed using npm.


1 Answers

This is now supported in moment:

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

Documentation

like image 87
brian2013 Avatar answered Sep 28 '22 04:09

brian2013