js格式化时间的简单实例
Date.prototype.format=function(format){//author:meizz leto={ "M+":this.getMonth()+1,//月份 "d+":this.getDate(),//日 "H+":this.getHours(),//小时 "m+":this.getMinutes(),//分 "s+":this.getSeconds(),//秒 "q+":Math.floor((this.getMonth()+3)/3),//季度 "f+":this.getMilliseconds()//毫秒 }; if(/(y+)/.test(format)) format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)); for(letkino) if(newRegExp("("+k+")").test(format)) format=format.replace(RegExp.$1,(RegExp.$1.length==1)?(o[k]):(("00"+o[k]).substr((""+o[k]).length))); returnformat; }; vard=newDate(); d.format('yyyy/MM/ddHH:mm'); //"2016/11/2510:01"
以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持毛票票!