js gets the date of this week and this month

js gets the date of this week and this month 

 // 本周 

                    let day = new Date();
                    let num = day.getDay();
                    day.setDate(day.getDate() + 0-num); // 如果把周日看作第一天,那就改成0,如果把星期日看作本周最后一天,则改为7

// 本月 本月第一天
                    let day = new Date();
                    day.setDate(1);

 

Guess you like

Origin blog.csdn.net/qq706352062/article/details/112885464