zoukankan      html  css  js  c++  java
  • js日期范围初始化,得到前一个月的日期

    今天做时间范围的初始化设定,开始时间是当前时间的前一个月,终于找到完美的解决方案了。
    Date.prototype.format = function(format) {
        var o = {
            "M+" : this.getMonth() + 1, // month
            "d+" : this.getDate(), // day
            "h+" : this.getHours(), // hour
            "m+" : this.getMinutes(), // minute
            "s+" : this.getSeconds(), // second
            "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
            "S" : this.getMilliseconds()
        // millisecond
        }
        if (/(y+)/.test(format))
            format = format.replace(RegExp.$1, (this.getFullYear() + "")
                    .substr(4 - RegExp.$1.length));
        for ( var k in o)
            if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
                        : ("00" + o[k]).substr(("" + o[k]).length));
        return format;

    }

           
           var begin=new Date();
            var end=new Date();
            new Date(begin.setMonth((new Date().getMonth()-1)));
            var begintime= begin.Format("yyyy-MM-dd");
            var endtime=end.Format("yyyy-MM-dd");
            $('#txtBeginVisitTime').val(begintime);

            $('#txtEndVisitTime').val(endtime);

     

     





  • 相关阅读:
    scala学习资料
    maven安装scala插件
    关于 mod_python
    Python读取Excel数据
    Python展开一个嵌套的序列
    随手写的Java向文本文件写字符串的类
    Python三元表达式
    递归的概述
    一分钟让你明白CSS中的盒模型
    Python实现ID3算法
  • 原文地址:https://www.cnblogs.com/zuifengke/p/4109b514e6728fd6ba952a8c8ebf5ce5.html
Copyright © 2011-2022 走看看