Created
May 19, 2014 08:44
-
-
Save alanerzhao/8359d87b0d0e559b3756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//表情除理 | |
function replace_em(str){ | |
str = str.replace(/\</g,'<'); | |
str = str.replace(/\>/g,'>'); | |
str = str.replace(/\n/g,'<br/>'); | |
str = str.replace(/\[em_([0-9]*)\]/g,'<img src="face/$1.gif" border="0" />'); | |
return str; | |
} | |
//处理时间 | |
function format (date,format) { | |
var curDate = new Date(date); | |
var date = { | |
"M+": curDate.getMonth() + 1, | |
"d+": curDate.getDate(), | |
"h+": curDate.getHours(), | |
"m+": curDate.getMinutes(), | |
"s+": curDate.getSeconds(), | |
"q+": Math.floor((curDate.getMonth() + 3) / 3), | |
"S+": curDate.getMilliseconds() | |
}; | |
if (/(y+)/i.test(format)) { | |
format = format.replace(RegExp.$1, (curDate.getFullYear() + '').substr(4 - RegExp.$1.length)); | |
} | |
for (var k in date) { | |
if (new RegExp("(" + k + ")").test(format)) { | |
format = format.replace(RegExp.$1, RegExp.$1.length == 1 | |
? date[k] : ("00" + date[k]).substr(("" + date[k]).length)); | |
} | |
} | |
return format; | |
} | |
//格式化时间 | |
var d = format(obj.time_stamp,'yyyy-MM-dd hh:mm:ss') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment