下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
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; } } //how to use new Date().format('yyyy-MM-dd hh:mm:ss');
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。