EasyUI Datagrid Datetime(EasyUI DataGrid 时间格式化)

EasyUI DataGrid 时间格式化

方法一:

var Common = {



    //EasyUI用DataGrid用日期格式化

    TimeFormatter: function (value, rec, index) {

        if (value == undefined) {

            return "";

        }

        /*json格式时间转js时间格式*/

        value = value.substr(1, value.length - 2);

        var obj = eval('(' + "{Date: new " + value + "}" + ')');

        var dateValue = obj["Date"];

        if (dateValue.getFullYear() < 1900) {

            return "";

        }

        var val = dateValue.format("yyyy-mm-dd HH:MM");

        return val.substr(11, 5);

    },

    DateTimeFormatter: function (value, rec, index) {

        if (value == undefined) {

            return "";

        }

        /*json格式时间转js时间格式*/

        value = value.substr(1, value.length - 2);

        var obj = eval('(' + "{Date: new " + value + "}" + ')');

        var dateValue = obj["Date"];

        if (dateValue.getFullYear() < 1900) {

            return "";

        }



        return dateValue.format("yyyy-mm-dd HH:MM");

    },



    //EasyUI用DataGrid用日期格式化

    DateFormatter: function (value, rec, index) {

        if (value == undefined) {

            return "";

        }

        /*json格式时间转js时间格式*/

        value = value.substr(1, value.length - 2);

        var obj = eval('(' + "{Date: new " + value + "}" + ')');

        var dateValue = obj["Date"];

        if (dateValue.getFullYear() < 1900) {

            return "";

        }



        return dateValue.format("yyyy-mm-dd");

    }

};

上面这种方法在datagrid中试了,var obj = eval('(' + "{Date: new " + value + "}" + ')');这句跑不下去!

下面这种方法可以:

var date = new Date(parseInt("/Date(1359522345000)/".replace(/\/Date\((-?\d+)\)\//, '$1'))); 

alert(date.getFullYear() + "/" + date.getMonth() + "/" + date.getDate());

 

你可能感兴趣的:(datagrid)