過濾html標籤以及nbsp等
function contentFun (dot) {
var dotStr = "";
if (dot) {
dotStr = dot.replace(/<[^>]+>|&[^>]+;/g,"").trim();
dotStr = dot.replace(/<[^>]+>/g, "");
dotStr = dotStr.replace(/“/g, "");
dotStr = dotStr.replace(/”/g, "");
dotStr = dotStr.replace(/ /g, "");
}
return dotStr;
};
轉時間戳爲 yyyy-mm-dd h:m
function formateTime(unixtime){
if(!unixtime){
return "/"
}
var dateTime = new Date(parseInt(unixtime))
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1;
var day = dateTime.getDate();
var hour = dateTime.getHours();
var minute = dateTime.getMinutes();
var second = dateTime.getSeconds();
unixtime = year + '-' + ((month < 10) ? ('0' + month) : month) + '-' + ((day < 10) ? ('0' + day) : day) + ' ' + ((hour < 10) ? ('0' + hour) : hour) + ':' + ((minute < 10) ? ('0' + minute) : minute);
return unixtime;}