date - setting day of week in javascript - Stack Overflow

PHOTO EMBED

Sun Nov 08 2020 08:18:47 GMT+0000 (Coordinated Universal Time)

Saved by @ali_alaraby #javascript

var date, daytoset; // given: a Date object and a integer representing the week day

var currentDay = date.getDay();
var distance = daytoset - currentDay;
date.setDate(date.getDate() + distance);
content_copyCOPY

https://stackoverflow.com/questions/11789647/setting-day-of-week-in-javascript