sevendays


根据日期获取当前对应的周一到周日的日期方法

匿名 (未验证) 提交于 2019-12-02 23:38:02
1、根据传入的日期获取那个日期对应一周的时间 2、代码实例: var global_week = ["周一","周二","周三","周四","周五","周六","周日"], global_nowDate = moment().format("YYYY-MM-DD"); function dateGetWeek(date){ var that = this; var sevenDays = [], firstMonday = moment(date).startOf('isoWeek').format("YYYY-MM-DD"); for (var i=0;i<7;i++){ var item = moment(firstMonday).add(i,'days').format("YYYY-MM-DD"), itemMD = moment(firstMonday).add(i,'days').format("MM-DD"), itemFull = itemMD + "("+ global_week[i] +")", obj = {}; obj.label = itemFull; if (moment(item,"YYYY-MM-DD").isBefore(moment(global_nowDate,"YYYY-MM-DD"))) { obj.clsNme = "prev";

工具导航Map