MSSQL 中的 datetime 类型字段被 ASP.NET 查问并间接返回给客户端时失去的是相似于 /Date(1590940800000)/ 这样的格局,为了失去失常可读性的工夫格局可能须要前端独自再做一次转换操作,代码如下:
function GetCreateTime(time, is_full) {var dateObj = new Date(parseInt(time.match(/\/Date\((\d+)\)\//)[1]));
var month = dateObj.getMonth() + 1;
var day = dateObj.getDate();
var hour = dateObj.getHours();
var minute = dateObj.getMinutes();
var second = dateObj.getSeconds();
if (is_full) {if (month < 10) {month = "0" + month;}
if (day < 10) {day = "0" + day;}
if (hour < 10) {hour = "0" + hour;}
if (minute < 10) {minute = "0" + minute;}
if (second < 10) {second = "0" + second;}
}
var date = dateObj.getFullYear() + "-" + month + "-" + day + "" + hour +":"+ minute +":" + second;
return date;
}
其中 is_full 参数值如果为 true 则补全格局。