JSON数据中DateTime类型的处理方法

//json 数据中Date(12839730837)转换成时间函数
-----------------------------------------------------------------------
for (var i = 0; i < store.proxy.data.results; i++) {
    var temp_date = renderTime(store.proxy.data.rows[i].datatime);
    store.proxy.data.rows[i].datatime = temp_date;
}

function renderTime(data) {
    var da = eval('new ' + data.replace('/', '', 'g').replace('/', '', 'g'));
    return da.toLocaleDateString() + " " + da.toLocaleTimeString();
}


//在后台json转换Date(12839730837)为字符串
 temp_json = System.Text.RegularExpressions.Regex.Replace(temp_json, @"\\/Date\((\d+)\)\\/", match =>
{
     DateTime dt = new DateTime(1970, 1, 1);
     dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value));
     dt = dt.ToLocalTime();
     return dt.ToString("yyyy-MM-dd HH:mm:ss");
});

原文地址:https://www.cnblogs.com/sunleinote/p/2248598.html