0 points

date - setting day of week in javascript - Stack Overflow


dashboard

Sun Nov 08 2020 08:18:47 GMT+0000 (UTC)

Posted 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_copy Copy

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