surazzarus
surazzarus

Reputation: 792

momentJs add days returns moment object instead of date

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

Upvotes: 2

Views: 2001

Answers (1)

full-stack
full-stack

Reputation: 553

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();

Upvotes: 4

Related Questions