Is there a simple/built in way of figuring out the current financial quarter?
ex:
1+ you can do something like the following: moment(). quarter() returns the current quarter number: 1, 2, 3, 4. 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.
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.
This is now supported in moment:
moment('2014-12-01').utc().quarter() //outputs 4 moment().quarter(); //outputs current quarter ie. 2
Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With