To get current date with Moment and JavaScript, we use the moment function without any arguments. const datetime = moment(); to call moment to get a moment object with the current date.
This is a pretty robust function for adding time to an existing moment. To add time, pass the key of what time you want to add, and the amount you want to add. moment(). add(7, 'days');
to create the tomorrow variable that's set to a moment object with today's date. Then we call add with -1 and 'days' to subtract one day to today. And then we call format with 'YYYY-MM-DD' to format the date to YYYY-MM-DD format.
Just call moment as a function without any arguments:
moment()
For timezone information with moment, look at the moment-timezone
package: http://momentjs.com/timezone/
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