jqgrid 时间戳转换成日期格式
原文 :http://blog.csdn.net/caoyuancsdn/article/details/52984524
Java script 接收到的时间参数是时间戳*1000
function bindDatePlug() {
$(".time").addClass('Wdate');
$(".time").on('focus', function() {
WdatePicker({
skin : 'whyGreen',
dateFmt : 'yyyy-MM-dd HH:mm:ss',
readOnly : true,
maxDate : "%y-%M-%d %H:%m:%s"
});
});
}
(function($) {
// jqgrid插件
$.hd_jqGrid = function(){};
$.extend($.hd_jqGrid, {
defaults : {
rightHtml : "<font color='green'>√</font>",
wrongHtml : "<font color='red'>×</font>",
date_yyyy_MM_dd_HH_mm_ss : "yyyy-MM-dd HH:mm:ss",
date_yyyy_MM_dd : "yyyy-MM-dd"
},
dateTimeFormatter : function(cellvalue, fmt) {
return (null != cellvalue && cellvalue > 0) ? $.method.dateFormat(cellvalue, fmt) : "";
},
statusFormatter : function(cellvalue) {
return cellvalue == 1 ? $.hd_jqGrid.defaults.rightHtml : $.hd_jqGrid.defaults.wrongHtml;
}
});
})(jQuery);
(function ($) {
$.method = function(){};
$.extend($.method, {
dateFormat : function( time, fmt) { // author: meizz
if(null == fmt || typeof fmt == "undefined" || $.trim(fmt).length == 0){
fmt = "yyyy-MM-dd HH:mm:ss";
}
if(typeof time == "number"){
time = new Date(time);
}
var o = {
"M+" : time.getMonth() + 1, // 月份
"d+" : time.getDate(), // 日
"h+" : time.getHours(), // 小时
"H+" : time.getHours(), // 小时
"m+" : time.getMinutes(), // 分
"s+" : time.getSeconds(), // 秒
"q+" : Math.floor((time.getMonth() + 3) / 3), // 季度
"S" : time.getMilliseconds() // 毫秒
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (time.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;
}
});
})(jQuery);
引用
{
name : 'act_time',
index : 'act_time',
width : 70, formatter : function(cellvalue, options, rowObject) {
return $.hd_jqGrid.dateTimeFormatter(cellvalue);
}
}
jqgrid 时间戳转换成日期格式的更多相关文章
- js angular 时间戳转换成日期格式 年月日 yyyy-MM-dd
昨天写项目,要把时间戳转换成日期格式发给后端 我就去网上找 看到的一些都不是我想要的 索性自己就写了一个如图 下面是angular 模式 $scope.getMyDate = function(str ...
- js将时间戳转换成日期格式-陈远波
var timestamp =1539598555000;//时间戳 //时间戳转换成time格式function timestampToTime(timestamp) { var date = ne ...
- vue 将时间戳转换成日期格式 (一)
(1)创建一个处理时间格式的js,内容如下: ../../utils/formatDate.js export function formatDate(date, fmt) { if (/(y+)/. ...
- javaScript中将时间戳转换成日期格式
function DateFormt(time, format) { ); var o = { , "d+": testDate.getDate(), "h+" ...
- js时间戳转成日期格式
将时间戳转换成日期格式:// 简单的一句代码var date = new Date(时间戳); //获取一个时间对象 注意:如果是uinx时间戳记得乘于1000.比如php函数time()获得的时间戳 ...
- javascript时间戳转换成指定格式的日期
//时间戳转换成指定格式的日期DateTool.IntDatetimeTo = function(time, format){ var testDate = new Date(time); ...
- moment使用,把某个时间时间戳转换成日期
1.某个时间时间戳转换成日期 moment(时间戳 ).format("YYYYMMDD") 2.获取某个日期当月的最后一天 moment(“2019-04-05”).endO ...
- CTime,Systemtime的比较还有转换成日期格式。
vc为我们提供了两种日期型的变量. 一种是CTime.他的缺点就是年份只支持到2038年,以后的日期就不支持啦,如果你的项目有20-30年的寿命,你就选择使用SYSTEMTIME.这个时间函数来进行比 ...
- js中时间戳转换成时间格式
js中时间戳转换成时间格式, // 时间戳转换成时间格式 var formatDate = function(date){ date = new Date(date); var y=date.getF ...
随机推荐
- java 工厂模式 转载
下面介绍三种设计模式,简单工厂模式,工厂方法模式,抽象工厂模式 思考如下场景: 有一天,林同学准备去买笔记本,他到商城发现有两款电脑他特别喜欢, 一款是 Macbook Pro, 另一款是 Surfa ...
- Azure系列2.1.12 —— CloudBlobDirectory
(小弟自学Azure,文中有不正确之处,请路过各位大神指正.) 网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习 ...
- LLVM的安装
1. 官网下载 llvm 2. 官网下载cmake 3. configure 执行 llvm 发现报错 4. 解压缩 cmake 5.将cmake 下面的bin 目录放到环境变量里面去 6. 创建一个 ...
- Oracle 条件判断函数decode和case when then案例
--decode条件判断函数 ,,,,,) from dual --需求:不通过连表查询,显示业主类型名称列的值 ,,,'商业','其他') from t_owners --case when the ...
- MyCat数据库中间件 - 分库
MyCat MyCat用于解耦分布式数据库与java,比如分库分表以后,需要查询某条数据时,需要java根据需要查的数据先计算去哪个库查,然而有了Mycat就不用自己计算怎么存储,怎么查询了.MyCa ...
- 排查 Maxwell can not find database 并且使用 MySQL binlog 解决相关问题
目前我们在使用 Maxwell 在读线上机器的 binlog 同步我们的离线数据库. 这次错误定位上,首先线要确定问题是发生在生产者 还是队列 还是消费者.经过查看各机器上任务的运行日志,定位到了问题 ...
- drf开发中常见问题
开发常见问题及解决 问题: 一.本地系统不能重现的bug 二.api接口出错不能及时的发现或难找到错误栈 三.api文档管理问题 四.大量的url配置造成url配置越来越多难以维护 五.接口不及时去更 ...
- Prism框架研究(二)
首先在介绍本节内容之前,首先来看看官方文档来如何描述Prism 应用的初始化吧!A Prism application requires registration and configuration ...
- 无法将从VSS中的解决方案添加到TFS的源代码管理器中
VSS是一种非常有用的项目文件管理工具,百度百科的解释是:VSS 的全称为 Visual Source Safe .作为 Microsoft Visual Studio 的一名成员,它主要任务就是负责 ...
- PLSQL过期:Your trial period for PL/SQL Developer is over .If you want to continue using this software ,you must purchase the retail version.
PLSQL过期:Your trial period for PL/SQL Developer is over .If you want to continue using this software ...