JSON返回时间格式转换

JSON返回时间格式为UTC: /Date(1294829766816)/

格式化为:2011-01-12

function changeDateFormat(cellval) {
 /// <summary>
 /// 改变时间格式
 /// </summary>
 /// <param name="cellval"></param>
 /// <returns type=""></returns>
    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;
}

原文地址:https://www.cnblogs.com/yxlblogs/p/3081633.html