دنبال کننده ها

۱۳۹۶ اسفند ۱۰, پنجشنبه

html - how to get the previous 4 sunday's of the current date javascript

[ad_1]



I wanna be able to get the previous 4 sunday's of the current date for example current date is
2018-3-1, I want to get 2018-2-25, 2018-2-18, 2018-2-11, 2018-2-4 only in javascript



I have this code but it only gave me the previous sunday of the current date



 var dt = new Date();
var currentWeekDay = dt.getDay();
var lessDays = currentWeekDay == 0 ? 6 : currentWeekDay - 0;
var sunday = new Date(new Date(dt).setDate(dt.getDate() -
lessDays));



[ad_2]

لینک منبع