EasyUI datagrid时间格式化

时间:13-04-16 栏目:EasyUI, web前端, web技术 作者:zongyan86 评论:0 点击: 20,507 次

效果如图:
Easyui DataGrid Time
Easyui DataGrid Time

//时间格式化
Date.prototype.format = function (format) {
if (!format) {
format = "yyyy-MM-dd hh:mm:ss";
}
var o = {
"M+": this.getMonth() + 1, // month
"d+": this.getDate(), // day
"h+": this.getHours(), // hour
"m+": this.getMinutes(), // minute
"s+": this.getSeconds(), // second
"q+": Math.floor((this.getMonth() + 3) / 3), // quarter
"S": this.getMilliseconds()
// millisecond
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
};
function fomatDateTime(str) {
return (new Date(parseInt(str.substring(str.indexOf('(') + 1, str.indexOf(')'))))).format("yyyy-MM-dd hh:mm:ss");
}

function fomatDate(str) {
return (new Date(parseInt(str.substring(str.indexOf('(') + 1, str.indexOf(')'))))).format("yyyy-MM-dd");
}



声明: 本文由( zongyan86 )原创编译,转载请保留链接: EasyUI datagrid时间格式化

关注我们