js 時(shí)間格式替代多余字符代碼
Date.prototype.format = function(style) {if(style==undefined || style==null) style='yyyy-MM-dd';var o = { 'M+' : this.getMonth() + 1, //month 'd+' : this.getDate(), //day 'h+' : this.getHours(), //hour 'm+' : this.getMinutes(), //minute 's+' : this.getSeconds(), //second 'w+' : '天一二三四五六'.charAt(this.getDay()), //week 'q+' : Math.floor((this.getMonth() + 3) / 3), //quarter 'S' : this.getMilliseconds() //millisecond}if(/(y+)/.test(style)) { style = style.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));}for(var k in o){ if(new RegExp('('+ k +')').test(style)){style = style.replace(RegExp.$1,RegExp.$1.length == 1 ? o[k] :('00' + o[k]).substr(('' + o[k]).length)); }}return style;};String.prototype.createShortDisp = function(text,num){if(num==undefined || num==null) num=10; var result=text; if (text.length > num) result = text.substring(0, num) + '...'; return '<span title = ’' + text + '’>' + result + '</>';}
相關(guān)文章:
1. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向2. asp(vbs)Rs.Open和Conn.Execute的詳解和區(qū)別及&H0001的說明3. CSS hack用法案例詳解4. PHP設(shè)計(jì)模式中工廠模式深入詳解5. 用css截取字符的幾種方法詳解(css排版隱藏溢出文本)6. ASP+ajax實(shí)現(xiàn)頂一下、踩一下同支持與反對的實(shí)現(xiàn)代碼7. JSP數(shù)據(jù)交互實(shí)現(xiàn)過程解析8. ThinkPHP5實(shí)現(xiàn)JWT Token認(rèn)證的過程(親測可用)9. asp中response.write("中文")或者js中文亂碼問題10. PHP session反序列化漏洞超詳細(xì)講解
