通过js计算本周属于该年度第几个星期,先获取系统日期然后再做判断,实用js计算脚本,结合自己的需求来修改使用。
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <SCRIPT Language="JavaScript"> <!-- function weekNo() { var totalDays = 0; now = new Date(); years=now.getYear() if (years < 1000) years+=1900 var days = new Array(12);// Array to hold the total days in a month days[0] = 31; days[2] = 31; days[3] = 30; days[4] = 31; days[5] = 30; days[6] = 31; days[7] = 31; days[8] = 30; days[9] = 31; days[10] = 30; days[11] = 31; // Check to see if this is a leap year if (Math.round(now.getYear()/4) == now.getYear()/4) { days[1] = 29 }else{ days[1] = 28 }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) // If this is January no need for any fancy calculation otherwise figure out the // total number of days to date and then determine what week if (now.getMonth() == 0) { totalDays = totalDays + now.getDate(); }else{ var curMonth = now.getMonth(); for (var count = 1; count <= curMonth; count++) { totalDays = totalDays + days[count - 1]; } totalDays = totalDays + now.getDate(); } var week = Math.round(totalDays/7); return week; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) document.write("现在是第 <b>"+weekNo()+"</b> 个星期("+years+"年)") // --> </SCRIPT>
本文来自武鸣人网站,转载请注明出处