Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change week day index in time

I want to set week day index (not month day) in time

for example:

"2021-11-01T10:50:02+04:00" should be converted to "2021-11-08T10:50:02+04:00"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"2021-11-02T10:50:02+04:00" should be converted to "2021-11-08T10:50:02+04:00"

and so on

basically my task is to convert any week day to friday

>Solution :

So update myDate to Friday (in current week), you could do something like this:

var dayToSet = 5; // Friday
var currentDay = myDate.getDay();
var distance = dayToSet - currentDay;
myDate.setDate(myDate.getDate() + distance);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading