I want to get the previous saturday's date based on today's date, so if we are on tuesday, the date wanted would be 3 days ago. Also, if today is saturday then this will be counted as the previous saturday.
for example:
today = Tuesday 09, July 2019
previous saturday => Saturday, 06 July 2019
next friday => Friday, 12 July
And if today is Saturday then :
today = Saturday, 13 July 2019
previous saturday = Saturday, 13 July 2019
next friday = Friday, 20 July 2019
following Niet's answer here's my code but i'm still getting the wrong dates:
var dateObj = new Date() // friday July 19
dateObj.setDate(dateObj.getDate() - (6-dateObj.getDay())) // gives me thursday, 18 July
dateObj.setDate(dateObj.getDate() + 6) // gives me wednesday, 24 July