通過(guò)返回的json 格式數(shù)據(jù),時(shí)間是用時(shí)間戳表示的,如以下數(shù)據(jù)

json數(shù)據(jù)
可以通過(guò) temple 屬性格式化時(shí)間, 向layui table表頭中添加templet : "<div>{{layui.util.toDateString(d.ordertime, 'yyyy-MM-dd HH:mm:ss')}}</div>",就可以格式化字符串
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>layui表格渲染,時(shí)間問(wèn)題</title>
<link rel="stylesheet" href="./css/layui.css" media="all">
<script src="./js/layui.all.js"></script>
<style type="text/css">
body{overflow-y: scroll;}
</style>
</head>
<body>
<table id="demo" lay-filter="test"></table>
<script>
layui.use('table', function(){
var table = layui.table;
//第一個(gè)實(shí)例
table.render({
elem: '#demo'
,height: 315
,url: 'http://localhost:8080/springmvc09_LayuiTable/getCar.action' //數(shù)據(jù)接口
,page: true //開(kāi)啟分頁(yè)
,cols: [[ //表頭
{field: 'id', title: 'ID', sort: true, fixed: 'left'}
,{field: 'name', title: '用戶(hù)名'}
,{field: 'pwd', title: '性別'}
,{field: 'date', title: '注冊(cè)時(shí)間', templet : "<div>{{layui.util.toDateString(d.ordertime, 'yyyy年MM月dd日 HH:mm:ss')}}</div>"}
]]
});
});
</script>
</body>
</html>
效果:

image.png
yyyy年MM月dd日 可以根據(jù)需要改。