easyui显示时间格式问题
来源:互联网 发布:德国联邦网络局 编辑:程序博客网 时间:2024/05/22 05:14
问题是:在SQL SERVER中时间是DataTime类型,用esayui的datagrid显示时,时间格式有问题。
源代码是:
用js书写的datagrid
<span style="font-size:18px;"> window.onload = function () { initTable(); } //初始化表格 function initTable() { $('#dg').datagrid({ //定位到Table标签,Table标签的ID是test fitColumns: true, url: '/InquiryReports/LoadPages', //指向后台的Action来获取当前用户的信息的Json格式的数据 title: '报表', //标识 nowrap: true, autoRowHeight: true, striped: false, collapsible: false, pagination: false, rownumbers: true, sortOrder: 'asc', remoteSort: false, idField: 'ChoseCourseID', singleSelect: false, columns: [[{ title: '表名', field:'TableName',width:100,align:'center' },{ title: '表ID', field: 'TableID', hidden: true, width: 80, align: 'center' },{ title: '单位名称', field: 'UnitName', width: 100, align: 'center' },{ title: '单位ID', field: 'UnitID', hidden: true, width: 50, align: 'center' },{ title: '填报人员', field: 'User', width: 50, align: 'center' },{title: '填报时间', field: 'Date', width: 100, align: 'center', ]] }); }</span>
页面显示:
解决办法:
<span style="font-size:18px;"> window.onload = function () { initTable(); } //初始化表格 function initTable() { $('#dg').datagrid({ //定位到Table标签,Table标签的ID是test fitColumns: true, url: '/InquiryReports/LoadPages', //指向后台的Action来获取当前用户的信息的Json格式的数据 title: '报表', //标识 nowrap: true, autoRowHeight: true, striped: false, collapsible: false, pagination: false, rownumbers: true, sortOrder: 'asc', remoteSort: false, idField: 'ChoseCourseID', singleSelect: false, columns: [[{ title: '表名', field:'TableName',width:100,align:'center' },{ title: '表ID', field: 'TableID', hidden: true, width: 80, align: 'center' },{ title: '单位名称', field: 'UnitName', width: 100, align: 'center' },{ title: '单位ID', field: 'UnitID', hidden: true, width: 50, align: 'center' },{ title: '填报人员', field: 'User', width: 50, align: 'center' },{ title: '填报时间', field: 'Date', width: 100, align: 'center',</span>
<span style="font-size:18px;"> formatter: function (date) { var pa = /.*\((.*)\)/; var unixtime = date.match(pa)[1].substring(0, 10); return getTime(unixtime); }}, ]] }); } function getTime(/** timestamp=0 **/) { var ts = arguments[0] || 0; var t, y, m, d, h, i, s; t = ts ? new Date(ts * 1000) : new Date(); y = t.getFullYear(); m = t.getMonth() + 1; d = t.getDate(); h = t.getHours(); i = t.getMinutes(); s = t.getSeconds(); // 可根据需要在这里定义时间格式 return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s); }</span>
结果:
成功解决。
0 0
- easyui显示时间格式问题
- jQuery EasyUI时间戳自定义时间显示格式类型
- 自定义EasyUI的datetimebox控件日期时间的显示格式
- EasyUI 时间格式验证
- GridView中显示时间日期格式问题
- GridView中显示时间日期格式问题
- json格式的时间显示问题
- GridView中显示时间日期格式问题
- 24小时格式时间显示有关问题
- .NET MVC 时间格式View显示问题
- GridView中显示时间日期格式问题
- bootstrap中时间显示格式问题
- easyui列表中的/Date(1352649600000)/时间显示的问题
- easyui datagrid 时间格式转化
- easyUI datetimebox 自定义显示格式
- easyUI datetimebox 自定义显示格式
- easyUI datetimebox 自定义显示格式
- 【EasyUi】自定义日期显示格式
- Knn-案例
- 【测试入门系列】Maven是什么
- 适用于JFinal的一个SQL Select和SqlExceptSelect的生成器
- ZOJ 3195 LCA
- AndroidSQlite增删查更新操作,listview展示带长按和代码注释
- easyui显示时间格式问题
- Android中获取location永为null
- 仅通过包名启动应用方法
- Calling C/C++ functions from C#
- Tensorflow安装
- PAT-B 1026. 程序运行时间
- 3分钟理解tintColor是个啥玩意
- 软件测试基础知识
- Log4J使用笔记