zoukankan      html  css  js  c++  java
  • easyui表格里的时间戳转换成日期格式

    1.第一步 写以下方法来格式化日期

    Date.prototype.format = function (format) {  
        var o = {  
            "M+": this.getMonth() + 1, // month  
            "d+": this.getDate(), // day  
            "h+": this.getHours(), // hour  
            "m+": this.getMinutes(), // minute  
            "s+": this.getSeconds(), // second  
            "q+": Math.floor((this.getMonth() + 3) / 3), // quarter  
            "S": this.getMilliseconds()  
            // millisecond  
        }  
        if (/(y+)/.test(format))  
            format = format.replace(RegExp.$1, (this.getFullYear() + "")  
                .substr(4 - RegExp.$1.length));  
        for (var k in o)  
            if (new RegExp("(" + k + ")").test(format))  
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));  
        return format;  
    }  

    2.第二步 扩展的Date的format方法(上述插件实现)  

    function formatDatebox(value) {  

        if (value == null || value == '') {  
            return '';  
        }  
        var dt;  
        if (value instanceof Date) {  
            dt = value;  
        } else {  
            dt = new Date(value);  
        }  
      
        return dt.format("yyyy-MM-dd"); 

    3.第三部  写好那就用呗 下面绿色的代码

    $('#dg').datagrid({
        url:'../RampAcLimitFltAction/getAcLimitFltList2.do',
       columns:[[ 

               {field:'limitStart',title:'起始时间',100,align:'center',formatter: formatDatebox}, 
               {field:'limitEnd',title:'结束时间',100,align:'center',formatter: formatDatebox}

                 ]]

  • 相关阅读:
    题解-Quantifier Question
    题解-[WC2011]最大XOR和路径
    笔记-Recursive Queries
    树套树
    SG函数
    题解-Magic Ship
    分块
    文章根据时间段显示的微信名和微信号
    jquery 在页面上根据ID定位(jQuery锚点跳转及相关操作) 经典
    nginx配置反向代理
  • 原文地址:https://www.cnblogs.com/yuner-angel/p/7930669.html
Copyright © 2011-2022 走看看