JQuery返回Json日期格式的问题/Date(1387900800000)/

来源:互联网 发布:三菱plc 编程手册 编辑:程序博客网 时间:2024/05/17 04:01

JQuery用ajax获得后台返回数据给前台用户显示,data日期数据显示/Date(1387900800000)/




JQuery和开发语言不一样,它没有封装好方法让它自动转换为日期,我们需要自己写一个方法,即可

function ChangeDateFormat(cellval) {    var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();    return date.getFullYear() + "-" + month + "-" + currentDate;}






阅读全文
0 0
原创粉丝点击