我就不吃芹菜

导航

 
{field: 'Time', title: '时间',
    formatter: function (value, row, index) {
        var date = new Date(value);
        var year = date.getFullYear().toString();
        var month = (date.getMonth() + 1);
        var day = date.getDate().toString();
        var hour = date.getHours().toString();
        var minutes = date.getMinutes().toString();
        var seconds = date.getSeconds().toString();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        if (hour < 10) {
            hour = "0" + hour;
        }
        if (minutes < 10) {
            minutes = "0" + minutes;
        }
        if (seconds < 10) {
            seconds = "0" + seconds;
        }
        return year + "/" + month + "/" + day + " " + hour + ":" + minutes + ":" + seconds;
    }
},

另一个方法, 这个比较简单, 但是功能不如上面的好

{field:'Time',title:'时间',  
    formatter:function(value,row,index) {  
        var unixTimestamp = new Date(value);  
        return unixTimestamp.toLocaleString();  
    }  
},  

 

posted on 2016-02-19 20:25  我就不吃芹菜  阅读(454)  评论(0编辑  收藏  举报