zoukankan      html  css  js  c++  java
  • myDataUtil。js


    Date.prototype.Format = function(fmt)
    {
    //author: meizz
    var o =
    {
    "M+" : this.getMonth() + 1, //month
    "d+" : this.getDate(), //day
    "h+" : this.getHours(), //hours
    "m+" : this.getMinutes(), //munutes
    "s+" : this.getSeconds(), //seconds
    "q+" : Math.floor((this.getMonth() + 3) / 3), //floor
    "S" : this.getMilliseconds() //milliseconds
    };
    if (/(y+)/.test(fmt))
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
    }


    Date.prototype.addDays = function(d)
    {
    this.setDate(this.getDate() + d);
    };


    Date.prototype.addWeeks = function(w)
    {
    this.addDays(w * 7);
    };


    Date.prototype.addMonths= function(m)
    {
    var d = this.getDate();
    this.setMonth(this.getMonth() + m);

    if (this.getDate() < d)
    this.setDate(0);
    };


    Date.prototype.addYears = function(y)
    {
    var m = this.getMonth();
    this.setFullYear(this.getFullYear() + y);

    if (m < this.getMonth())
    {
    this.setDate(0);
    }
    };

    function getUpMonth(){
    var up = new Date();
    up.setMonth(up.getMonth()-1);
    var up_year=up.getFullYear();
    var up_month=up.getMonth()+1;
    var up_day=up.getDate();
    if(up_month<10){
    up_month="0"+up_month;
    }
    if(up_day<10){
    up_day="0"+up_day;
    }
    return up_year+"-"+up_month+"-"+up_day;
    };
    function getThisMonth(){
    var now = new Date();
    var now_year=now.getFullYear();
    var now_month=now.getMonth()+1;
    var now_day=now.getDate();
    if(now_month<10){
    now_month="0"+now_month;
    }
    if(now_day<10){
    now_day="0"+now_day;
    }
    return now_year+"-"+now_month+"-"+now_day;
    };

    -------------------------

    var begin = new Date();
    begin.addMonths(-1);
    var end=new Date();

    if($("input[name=beginDate]").val()==""){
    $("input[id='beginDate']").val(begin.Format("yyyy-MM-dd"));
    }
    if($("input[name=endDate]").val()==""){
    $("input[name=endDate]").val(end.Format("yyyy-MM-dd"));
    }

  • 相关阅读:
    php json_decode无法处理解决方法
    jquery ajax怎么使用jsonp跨域访问
    jquery ajax怎么使用jsonp跨域访问
    查看xml源码的方法
    php array_push 与 $arr[]=$value 性能比较
    生成个性二维码方法
    PHP匿名函数的写法
    PHP rand和mt_rand 区别
    C++ 顺序表
    线索树的建立与遍历
  • 原文地址:https://www.cnblogs.com/yangy608/p/2428837.html
Copyright © 2011-2022 走看看