zoukankan      html  css  js  c++  java
  • js获取当前日期一年的第几周

    获取当前日期一年中的第几周

     1     function theWeek() {
     2         var totalDays = 0;
     3         now = new Date();
     4         years = now.getYear()
     5         if (years < 1000)
     6             years += 1900
     7         var days = new Array(12);
     8         days[0] = 31;
     9         days[2] = 31;
    10         days[3] = 30;
    11         days[4] = 31;
    12         days[5] = 30;
    13         days[6] = 31;
    14         days[7] = 31;
    15         days[8] = 30;
    16         days[9] = 31;
    17         days[10] = 30;
    18         days[11] = 31;
    19         //判断是否为闰年,针对2月的天数进行计算
    20         if (Math.round(now.getYear() / 4) == now.getYear() / 4) {
    21             days[1] = 29
    22         } else {
    23             days[1] = 28
    24         }
    25         if (now.getMonth() == 0) {
    26             totalDays = totalDays + now.getDate();
    27         } else {
    28             var curMonth = now.getMonth();
    29             for (var count = 1; count <= curMonth; count++) {
    30                 totalDays = totalDays + days[count - 1];
    31             }
    32             totalDays = totalDays + now.getDate();
    33         }
    34         //得到第几周
    35         var week = Math.round(totalDays / 7);
    36         return week;
    37     }
  • 相关阅读:
    Eclipse中项目去除Js验证
    Web安全扫描工具
    Oracle-定时任务
    About_Return
    About_php_封装函数
    About_PHP_函数
    About_PHP_验证码的生成
    About_PHP_文件的上传
    About_MySQL Select--来自copy_03
    About_AJAX_03
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/11633806.html
Copyright © 2011-2022 走看看