js获取 本周,本月的日期

js获取 本周,本月的日期 

 // 本周 

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

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

猜你喜欢

转载自blog.csdn.net/qq706352062/article/details/112885464
今日推荐