Search code examples
javascriptmomentjsschedule

How can I get a specific date with MomentJS?


How can I get a specific date with MomentJS?

For example: I would like start generating days from March 1 2020.

Thanks!


Solution

  • According to their docs you can parse a text date into a moment object:

    var myDate = moment("2020-03-01");

    From: https://momentjs.com/docs/#/parsing/string/

    After that you can add time (days) to the object:

    myDate.add(1, 'days');

    From: https://momentjs.com/docs/#/manipulating/add/