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"
以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持毛票票!
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短