Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
       Date.prototype.format = function(format) {
            
var args = {
                
"M+"this.getMonth() + 1,
                
"d+"this.getDate(),
                
"h+"this.getHours(),
                
"m+"this.getMinutes(),
                
"s+"this.getSeconds(),
                
"q+": Math.floor((this.getMonth() + 3/ 3),  
                
"S"this.getMilliseconds()
            };
            
if (/(y+)/.test(format))
                format 
= format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            
for (var i in args) {
                
var n = args[i];
                
if (new RegExp("(" + i + ")").test(format))
                    format 
= format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
            }
            
return format;
        };
posted on 2015-07-13 16:48 ccsdu2009 阅读(337) 评论(0)  编辑 收藏 引用 所属分类: 杂项

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理