Ajax传回的日期为/Date239000000000格式

js:

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();
    var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
    var min = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + min;
}

使用function的方法:

   var a = ChangeDateFormat(res.StartTime);

版权声明:本文为weixin_37778355原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。