I’m working on a real estate project for a while. I needed to add days to JavaScript Date object for a set new date to a Datepicker component. Probably you will not need to use JavaScript Date object.
Buefy’s Datepicker component requires JavaScript date object unless you use your own date parser. Anyway, I had a Datepicker component like that;
<b-datepicker disabled v-model="endDate" placeholder="Select Date" icon="calendar-today"> </b-datepicker>
In order to add days to JavaScript’ Date object, you can use Moment.js like that;
moment(new Date()).add(7, 'days').toDate()
You should be careful, Date() and new Date() are different things when you use Date object. If you use Date() directly, this will be a string. If you use with new keyword this will be an object. So, in this case, I’ll use like that;
this.endDate = moment(new Date()).add(7, 'days').toDate()
I hope this will help you.