easyUi的dataGrid格式化日期时间

如果返回的时间格式是一长串数字,需要转换成日期时间格式,可使用以下方法:

{
     title: '发起时间',
     field: 'time',
     formatter : function(value, row, index) {
                    var date = new Date(value.time); 
                    var dateTime = date.toLocaleString(); 
                    dateTime = dateTime.replace(new RegExp("/", 'g'),"-");
                    return '<span title="'+dateTime+'">'+dateTime+'</span>';
    },
     width: 200
}

猜你喜欢

转载自blog.51cto.com/1197822/2156831