更新时间:2023-02-03 15:23:04
返回的是自纪元以来的毫秒数.你可以这样做:
What is returned is milliseconds since epoch. You could do:
var d = new Date();
d.setTime(1245398693390);
document.write(d);
关于如何完全按照您的需要设置日期格式,请参阅 http://www.w3schools.com/jsref/jsref_obj_date.asp
On how to format the date exactly as you want, see full Date
reference at http://www.w3schools.com/jsref/jsref_obj_date.asp
您可以通过解析整数(如此处建议)来去除非数字:
You could strip the non-digits by either parsing the integer (as suggested here):
var date = new Date(parseInt(jsonDate.substr(6)));
或者应用以下正则表达式(来自评论中的 Tominator):
Or applying the following regular expression (from Tominator in the comments):
var jsonDate = jqueryCall(); // returns "/Date(1245398693390)/";
var re = /-?d+/;
var m = re.exec(jsonDate);
var d = new Date(parseInt(m[0]));