How to set day of a date in moment?

Viewed 19677

I want to set the date to another day, then add 1 to the date.

    onModalPrevDate=()=>{
        this.closeModal();
        let d=this.state.selectedDay;
        let dateContext = Object.assign({}, this.props.dateContext);
        let c=moment(dateContext).set("days",d);  //not working as intended
        let f=moment(c).add(1,"day");
        let a=f.format("D");
        this.onDayClick(a);
    }

moment(dateContext).set("days",d); is not working as intended. have tried "day" instead of "days" still not working.

1 Answers

use "date" instead of "days"

let c=moment(dateContext).set("date",d); 
Related