2

I want to add 7 days in the date using momentJs in angular project.

let nextRunAt = "2018-08-16T02:00:00.242Z";

let calculatedRunAt = moment(nextRunAt).add(7, 'days');

I am expecting to get the date after 7 days but instead I get moment object.

Like below enter image description here

Any help is appreciated. Thanks

surazzarus
  • 772
  • 5
  • 17
  • 32
  • Possible duplicate of [Moment.js transform to date object](https://stackoverflow.com/questions/17987647/moment-js-transform-to-date-object) – user184994 Aug 14 '18 at 20:16

1 Answers1

4

The moment method returns a moment object, you have to convert it to date-

let calculatedRunAt = moment(nextRunAt, "DD-MM-YYYY").add(7, 'days').toDate();
full-stack
  • 553
  • 5
  • 20
  • thankyou for the answer.. Also is there a way that I can get the `calculatedRunAt` as the same format to `nextRunAt`... I have updated my question – surazzarus Aug 14 '18 at 21:09