easyUI格式化显示Date类型的时间数据
2018-03-02 17:50
501 查看
字段的类型为Date,后台返回到前端的时间不加处理将会显示成“Feb 27, 2018 12:00:00 AM”,显然,这不是我们所想要的格式,那应该如何处理呢?新建一个格式化显示时间的js: dateFormat.js,输入以下内容:
然后在页面中引入该js,最后在column的field中调用该js声明的dateFormatter即可。示例:
/** * 时间格式化 * @param value * @returns {string} */ function dateFormatter (value) { var date = new Date(value); var year = date.getFullYear().toString(); var month = (date.getMonth() + 1); var day = date.getDate().toString(); var hour = date.getHours().toString(); var minutes = date.getMinutes().toString(); var seconds = date.getSeconds().toString(); if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } if (hour < 10) { hour = "0" + hour; } if (minutes < 10) { minutes = "0" + minutes; } if (seconds < 10) { seconds = "0" + seconds; } return year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds; }
然后在页面中引入该js,最后在column的field中调用该js声明的dateFormatter即可。示例:
{field:'VISITDATE',title:'随访时间',width:150,align:'center',formatter:function(value,row,index){return dateFormatter(value);}},
相关文章推荐
- 解决easyui 中显示Date类型数据为[object Object],json中格式化日期
- Jsp格式化显示Date类型数据
- Json化后的时间类型数据在Extjs Grid中的显示问题
- Mybatis 插入数据的时候Date类型,时间精度丢失
- easyUI datebox 日期空间斜杠格式化。例如将日期空间中显示2017-03-13,改为2017/03/13
- Easyui获取数据库date数据的显示
- java web中日期Date类型在页面中格式化显示的三种方式
- JAVA将十位时间戳格式化为日期Date类型
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- EasyUi-Datagrid Date类型格式化
- JAVA将十位时间戳格式化为日期Date类型
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- js的 new Date()日期格式化显示以及js获取时间戳
- 将date类型的数据在json输出时格式化
- jstl foreach标签格式化date,string类型数据
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- JAVA将十位时间戳格式化为日期Date类型
- JS中写Date日期类型的数据,要求具体格式化.