关于js接收后台时间戳转换成时间问题

后台回传数据  
work[name:"...",id:"...",checkdata:"2017-7-28".....]
经过toJSONString后checkdata变成了4141415765415(时间戳)
        List<Work> works=this.workBiz.findWork(classid, semester, checkDate,page,rows);
        int total=workBiz.findworknum(classid,null,null,null);
    Map<String,Object> map=new HashMap<String,Object>();
        map.put("rows", works);
        map.put("total", total);
        jsonStr=JSON.toJSONString(map);

前台js代码

datagrid=$("#show_find_checkwork").datagrid({  
        url:"/Examination2.0/work_findWorkresult.action",//加载的URL  
        pagination:true,//显示分页  
        pageSize:10,//分页大小  
        pageList:[5,10,15,20],//每页的个数  
        fit:true,//自动补全  
        toolbar : '#find_table_slelct',
        fitColumns:true,  
        queryParams : {
            examineeclassid:classname,
            chackdate:checkDate,
            semester:semester,
            editionid:editionid,
            subjectid:subjectid,
            chapterid:chapterid,
        },
        iconCls:"icon-save",//图标  
        columns:[[      //每个列具体内容  
                        {  
                            field:'wid',  
                            title:'编号',  
                            width:50,  
                        },     
                        {field:'wname',title:'作业名',align :'center',width:100},     
                        {field:'checkdate',title:'检查时间',align : 'center',width:100,
                            formatter : function(value, row, index) {
                                return change(row.checkdate)
                            }}, 
                        {field:'description',title:'作业描述',align : 'center',width:200},
                        {field:'remark',title:'备注',align : 'center',width:100} ,
                        {field:'result',title:'操作',align : 'center',width:100,
                            formatter : function(value, row, index) {
                                if(row.result!=null&&row.result!=""&&row.result!=undefined){
                                    return '<a href=\"changefindwork.jsp?wid='+row.wid+'">查看</a>';
                                }else{
                                    return '<label>未检查</label>';
                                }

                            }} 
                        ]]  
    }) 

将时间戳转换成data并用正则表达式去掉无用数据

function change(data) {
        var birthday = new Date(data);
        var time=birthday.toLocaleString()
        //"2017/7/28 上午 12:12:12"
        time=time.replace(/上午(\w|:)*/,"");
        //"2017/7/28 "
        //time=time.replace(/\s$/,"");
        return time;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值