moment.js add/subtract days without affecting the original date

Viewed 11974

How do you add or subtract days to a default date using moment.js?

I am trying to get the start and end dates of the week like below:

const current = moment.tz('2016-03-04', 'America/Los_Angeles');
const startOfWeek = current.startOf('isoWeek').weekday(0);
const endOfWeek = current.endOf('isoWeek').weekday(6);

When calling endOfWeek, I am getting the expected value. However, my problem is that startOfWeek is overridden by the endOfWeek value.

I wanted to get the value of both startOfWeek and endOfWeek

3 Answers
Related