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 里如何实现线程间通信(转载)
出处:http://www.importnew.com/26850.html 正常情况下,每个子线程完成各自的任务就可以结束了.不过有的时候,我们希望多个线程协同工作来完成某个任务,这时就涉及到了线程 ...
- [转帖]2015年时微软Win3.1崩溃迫使巴黎奥利机场短暂关闭
https://www.ithome.com/html/it/188796.htm IT之家讯 2015年11月14日消息,上周法国巴黎奥利机场因为微软的Windows 3.1系统出现故障不得不迫使所 ...
- CMake--变量
1.一般变量 1)CMake变量引用的方式 使用${}进行变量的引用.例如: ${PROJECT_NAME} #返回项目名称 在 IF 等语句中,是直接使用变量名而不通过${}取值. 2)cmake自 ...
- html5 datalist 选中option选项后的触发事件
使用input + datalist 实现自动补全功能,其中datalist中的内容是根据input输入的内容动态变换的,代码如下 <!DOCTYPE HTML> <html> ...
- css3特殊图形(气泡)
一.气泡 效果: body{ background: #dd5e9d; height: 100%; } .paopao { position: absolute; width: 200px; heig ...
- cookie,localStorage和sessionStorage区别
三者的异同 特性 Cookie localStorage sessionStorage 数据的生命期 一般由服务器生成,可设置失效时间.如果在浏览器端生成Cookie,默认是关闭浏览器后失效 除非被清 ...
- Python基础知识1-基础语法
pyenv--版本管理工具(后续再补)可参见https://www.jianshu.com/p/8aaf2525fa80 冯诺依曼体系架构 编程基础 语言分类 低级语言到高级语言 高级语言 程序Pr ...
- 百度云虚拟主机配置 Thinkphp5.1
材料 服务器:百度云虚拟主机(nginx+php7.0+linux) Thinkphp 5.1 问题 百度云默认目录为/webroot,但是我们的需求是将项目存放到/webroot/public下面. ...
- DFI LP DK P45 T2RS PLUS BIOS SETTING
standard cmos features date (mm:dd:yy) mon,oct 11 2016 time (hh:mm:ss) 10 : 10 : 26 ide channel 0 sa ...
- Spring Boot 构建电商基础秒杀项目 (八) 商品创建
SpringBoot构建电商基础秒杀项目 学习笔记 新建数据表 create table if not exists item ( id int not null auto_increment, ti ...