博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jqGrid时间转换
阅读量:4677 次
发布时间:2019-06-09

本文共 1427 字,大约阅读时间需要 4 分钟。

colModel: [            { label: '注册时间', name: 'createDate', index: 'create_date', width: 80, formatter:function(value,options,row){                return new Date(value).Format('yyyy-MM-dd HH:mm:ss');}}        ],

增加Date的prototype:

javascript Date format(js日期格式化):

// 对Date的扩展,将 Date 转化为指定格式的String// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) // 例子: // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 // (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function (fmt) { //author: meizz     var o = {        "M+": this.getMonth() + 1, //月份         "d+": this.getDate(), //日         "H+": this.getHours(), //小时         "m+": this.getMinutes(), //分         "s+": this.getSeconds(), //秒         "q+": Math.floor((this.getMonth() + 3) / 3), //季度         "S": this.getMilliseconds() //毫秒     };    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));    for (var k in o)    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));    return fmt;}调用: var time1 = new Date().Format("yyyy-MM-dd");var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");

 

其他方式可以参考如下的博客:

http://blog.csdn.net/liangxw1/article/details/50921462

转载于:https://www.cnblogs.com/gmq-sh/p/7580436.html

你可能感兴趣的文章
centos7 添加开机启动项
查看>>
luogu【P2745】[USACO5.3]窗体面积Window Area
查看>>
Codeforces 346D Robot Control(01BFS)
查看>>
CSS3学习笔记--media query 响应式布局
查看>>
NHibernate.3.0.Cookbook第四章第2节的翻译
查看>>
19.C#逐一介绍IEnumerable和IEnumerable<T>中的扩展方法(10.3-10.5)
查看>>
听说最近你读过不少书
查看>>
linux之Ubuntu下Django+uWSGI+nginx部署
查看>>
【转】Struts1.x系列教程(2):简单的数据验证
查看>>
HTML head元素
查看>>
requireJS
查看>>
Poj3667Hotel线段树
查看>>
待嫁闺中:PPTV的辛酸史
查看>>
作用域
查看>>
CSS文本方向
查看>>
Dev Grid拖拽移动行
查看>>
Read
查看>>
this关键字的构造方法的使用
查看>>
Spring的数据库操作---- Spring框架对JDBC的整合---- Spring的数据库操作
查看>>
2016/12/14---- C3P0
查看>>