EasyUi 时间戳问题
来源:互联网 发布:中国微软程序员工资 编辑:程序博客网 时间:2024/05/21 02:34
这段时间接触了Easyui 这确实是个不错的东西,不过也有许许多多的问题出现 需要一点一点解决。
在使用easyui的datagrid数据列表时 都数据库导过来的日期数据都莫名其妙的变成了一串数字,这玩意还有专属名 叫“时间戳”
总不能就这样显示让客户看吧,那怎么讲这日期进行格式化呢????看代码
1.第一步 写以下方法来格式化日期
Date.prototype.format = function (format) {
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;
}
2.第二步 扩展的Date的format方法(上述插件实现)
function formatDatebox(value) {
if (value == null || value == '') {
return '';
}
var dt;
if (value instanceof Date) {
dt = value;
} else {
dt = new Date(value);
}
return dt.format("yyyy-MM-dd");
}
3.第三部 写好那就用呗 下面绿色的代码
$('#dg').datagrid({
url:'../RampAcLimitFltAction/getAcLimitFltList2.do',
columns:[[
{field:'limitStart',title:'起始时间',width:100,align:'center',formatter: formatDatebox},
{field:'limitEnd',title:'结束时间',width:100,align:'center',formatter: formatDatebox}
]]
这样就好了 当然还有其他好多方法!!
- EasyUi 时间戳问题
- EasyUI datetimebox时间设置问题
- easyui显示时间格式问题
- easyui时间控件获取值问题
- easyui展示时间遇到的问题
- 关于easyui时间获取的问题
- easyui列表中的/Date(1352649600000)/时间显示的问题
- 前端easyUI时间控件datebox小bug问题修复
- easyUI日常问题之datagrid表格时间类型转换
- EasyUI[Jquery]将时间戳转化为时间格式
- jQuery EasyUI时间戳自定义时间显示格式类型
- easyui问题
- easyui问题
- easyUI datagrid 时间格式化
- EasyUI DataGrid 时间格式化
- EasyUI datetimebox 时间格式化
- EasyUI 日期时间框
- easyui将时间格式化
- 各种排序方法的优缺点
- 【ROS】计算机、机器人之间的网络通信配置
- Spring security 4 使用java注解进行登陆验证
- 数据结构课程设计 电子投票系统
- String中的null,"",以及String s;等等的区别详解
- EasyUi 时间戳问题
- JavaScript执行环境及作用域
- C-C++面试题2
- 63 leetcode - Unique Paths
- zabbix 临时关闭报警
- Thrift 服务器端的几种工作模式分析
- 最优合并问题
- JavaScript数据转换三——parseInt与parseFloat的区别及判别方式
- [欧拉回路] Codeforces 429E #245 (Div. 1) E. Points and Segments