zoukankan      html  css  js  c++  java
  • 两个日期之间的所有日期

    define的方式暴露了Util的公共方法

    begin直接获取开始时间 end直接获取结束时间 目前是把所有的日期放在了数组内,

    Util.dataDecline = function(begin,end){

    var result = [];

    Date.prototype.format = function() {  

          var s = '';  

          var mouth = (this.getMonth() + 1)>=10?(this.getMonth() + 1):('0'+(this.getMonth() + 1));  

          var day = this.getDate()>=10?this.getDate():('0'+this.getDate());  

          s += this.getFullYear() + '-'; // 获取年份。  

          s += mouth + "-"; // 获取月份。  

          s += day; // 获取日。  

          return (s); // 返回日期。  

      };  

      function getAll(begin, end) {  

          var ab = begin.split("-");  

          var ae = end.split("-");  

          var db = new Date();  

          db.setUTCFullYear(ab[0], ab[1] - 1, ab[2]);  

          var de = new Date();  

          de.setUTCFullYear(ae[0], ae[1] - 1, ae[2]);  

          var unixDb = db.getTime();  

          var unixDe = de.getTime(); 

          for (var k = unixDb; k <= unixDe;) {  

              result.push((new Date(parseInt(k))).format());

              k = k + 24 * 60 * 60 * 1000;  

          }

      }  

      getAll(begin, end);

      return result

    };

  • 相关阅读:
    php读取excel文件的实例代码
    PHP连接局域网MYSQL数据库的实例
    一个经典实用的iptables shell脚本
    PHP中strtotime函数使用方法分享
    php strtotime 函数UNIX时间戳
    解析php时间戳与日期的转换
    有关Mysql连接问题
    PHP获取时间日期的多种方法
    PHP引用符&的用法详细解析
    PHP获取与操作php.ini文件的几个函数示例
  • 原文地址:https://www.cnblogs.com/wuconghui/p/9213611.html
Copyright © 2011-2022 走看看