easyui datagrid 日间格化(JS 日期时间本地化显示)

easyui datagrid 日期时间显示不正常,后台java 类型为 DATE 经过JSON工具一转化传到前台来就是这样,不便 于是想格式化一下,

 

格式化代码 如下:

 

[javascript][/javascript] view plaincopyprint?

  1. $(‘#gridTable’).datagrid({
  2.             title: ‘系统通知及广告管理’,
  3.             loadMsg:’数据加载中,请稍后……’,
  4.             rownumbers: true,
  5.             pagination: true,
  6.             singleSelect: false,
  7.             pageSize: 10,
  8.             pageList: [5, 10, 15, 20],
  9.             fitColumns: true,
  10.             fit: true,
  11.             striped: true,
  12.             nowrap: false,
  13.             url: ‘list.do’,
  14.             idField:’mediaId’,
  15.             columns:[[
  16.                 {field:’id’,checkbox:true},
  17.                 {field:’system’,title:’适用系统’},
  18.                 {field:’infoType’,title:’消息类型’,
  19.                     formatter:
  20.                          function(value, row, index){
  21.                          if(value==1)
  22.                              return “文本”;
  23.                          if(value==2)
  24.                              return “图片”;
  25.                          if(value==3)
  26.                              return “视频”;
  27.                          else
  28.                              return “<span style=\”color:red\” >未知</span>”;
  29.                         }},
  30.                  {field:’title’,title:’标题’},
  31.                  {field:’content’,title:’内容’,width:140},
  32.                    {field:’issueTime’,title:’生效时间’,
  33.                      formatter:function(value,row,index){
  34.                          var unixTimestamp = new Date(value);
  35.                          return unixTimestamp.toLocaleString();
  36.                          }
  37.                     },
  38.                    {field:’disabledTime’,title:’失效时间’},
  39.                    {field:’userId’,title:’用户ID’},
  40.                    {field:’userName’,title:’操作员’}
  41.             ]],

 

格式化显示 正常,

 

标签