💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
通过时间日期查询 周次 ``` function getweek(z) { let day = Date.parse(z); //如果不是当年的第一天不是星期一,则该日所属周数为上一年的最后一周 day = new Date(day); if (day.getDay() !== 1) { day = day.getTime() - 24 * 60 * 60 * 1000 day = new Date(day); } day.setMonth(0); day.setDate(1); day.setHours(0); day.setMinutes(0); day.setSeconds(0);//到这里就得到该年的一月一日 let today = Date.parse(z); today = new Date(today); let todayWeek = today.getDay() //计算日期是一年中的第几天 let rankDay = Math.ceil((today.getTime() - day.getTime()) / (1000 * 24 * 60 * 60)) let rankWeek = Math.ceil(rankDay / 7) rankWeek = rankWeek < 10 ? ("0" + rankWeek) : rankWeek let year = day.getFullYear().toString() return year + rankWeek } getweek(new Date()) getweek('2019-05-05') //201918 ```