How do I get the first and last day and time of the current month in the following format in moment.js:
2016-09-01 00:00
I can get the current date and time like this:
moment().format('YYYY-MM-DD h:m')
which will output in the above format.
However I need to get the date and time of the first and last day of the current month, any way to do this?
EDIT: My question is different from this one because that asks for a given month that the user already has whereas I am asking for the current month along with asking for a specific format of the date that is not mentioned in the other so called 'duplicate'.
You can do this without moment.js
A way to do this in native Javascript code :
In case anyone missed the comments on the original question, you can use built-in methods (works as of Moment 1.7):
There would be another way to do this:
moment startOf() and endOf() is the answer you are searching for.. For Example:-
Assuming you are using a Date range Picker to retrieve the dates. You could do something like to to get what you want.