zoukankan      html  css  js  c++  java
  • jqgrid 时间戳转换成日期格式

    原文 :http://blog.csdn.net/caoyuancsdn/article/details/52984524

    Java script  接收到的时间参数是时间戳*1000

     1 function bindDatePlug() {  
     2     $(".time").addClass('Wdate');  
     3     $(".time").on('focus', function() {  
     4         WdatePicker({  
     5             skin : 'whyGreen',  
     6             dateFmt : 'yyyy-MM-dd HH:mm:ss',  
     7             readOnly : true,  
     8             maxDate : "%y-%M-%d %H:%m:%s"  
     9         });  
    10     });  
    11 }  
    12   
    13 (function($) {    
    14     // jqgrid插件  
    15     $.hd_jqGrid = function(){};  
    16     $.extend($.hd_jqGrid, {  
    17         defaults : {  
    18             rightHtml : "<font color='green'>√</font>",  
    19             wrongHtml : "<font color='red'>×</font>",  
    20               
    21             date_yyyy_MM_dd_HH_mm_ss : "yyyy-MM-dd HH:mm:ss",  
    22             date_yyyy_MM_dd : "yyyy-MM-dd"  
    23         },  
    24           
    25         dateTimeFormatter : function(cellvalue, fmt) {  
    26             return (null != cellvalue && cellvalue > 0) ? $.method.dateFormat(cellvalue, fmt) : "";  
    27         },  
    28           
    29         statusFormatter : function(cellvalue) {  
    30             return cellvalue == 1 ? $.hd_jqGrid.defaults.rightHtml : $.hd_jqGrid.defaults.wrongHtml;  
    31         }  
    32     });  
    33 })(jQuery);  
    34   
    35   
    36 (function ($) {  
    37     $.method = function(){};  
    38     $.extend($.method, {          
    39         dateFormat : function( time, fmt) { // author: meizz  
    40             if(null == fmt || typeof fmt == "undefined" || $.trim(fmt).length == 0){  
    41                 fmt = "yyyy-MM-dd HH:mm:ss";  
    42             }  
    43               
    44             if(typeof time == "number"){  
    45                 time = new Date(time);  
    46             }  
    47               
    48             var o = {  
    49                 "M+" : time.getMonth() + 1, // 月份  
    50                 "d+" : time.getDate(), //
    51                 "h+" : time.getHours(), // 小时  
    52                 "H+" : time.getHours(), // 小时  
    53                 "m+" : time.getMinutes(), //
    54                 "s+" : time.getSeconds(), //
    55                 "q+" : Math.floor((time.getMonth() + 3) / 3), // 季度  
    56                 "S" : time.getMilliseconds() // 毫秒  
    57             };  
    58             if (/(y+)/.test(fmt)) {  
    59                 fmt = fmt.replace(RegExp.$1, (time.getFullYear() + "").substr(4 - RegExp.$1.length));  
    60             }  
    61                   
    62             for ( var k in o) {  
    63                 if (new RegExp("(" + k + ")").test(fmt)) {  
    64                     fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
    65                 }  
    66             }  
    67             return fmt;  
    68         }  
    69     });  
    70 })(jQuery);  

    引用

     1 {  
     2   name : 'act_time',  
     3   index : 'act_time',  
     4   width : 70,   7   formatter : function(cellvalue, options, rowObject) {  
     8    return $.hd_jqGrid.dateTimeFormatter(cellvalue);  
     9    }  
    10 }
  • 相关阅读:
    css 深入理解
    2018 web经典面试题
    CSS 居中布局
    HTTP首部解析
    http状态码有那些?分别代表是什么意思?
    基本HTTP协议流程是什么?
    JS-变量
    javascript基础1
    css3弹性盒模型(Flexbox)
    文字效果和颜色
  • 原文地址:https://www.cnblogs.com/cmyxn/p/6803132.html
Copyright © 2011-2022 走看看