如何在javascript中从此/Date(1518696376959)/
获取日期时间?
我试过这样的
var d = new Date("1519192874994");
答案 0 :(得分:1)
我试过这样的var d = new Date(“1519192874994”);
无需将其包装在引号中,Date
构造函数将采用毫秒值(Number
)
var d = new Date(1519192874994) //Wed Feb 21 2018 11:31:14 GMT+0530 (India Standard Time)
来自"/Date(1518696376959)/"
成功
var str = "/Date(1518696376959)/";
var date = new Date( +str.match(/\d+/g)[0] ); //notice the unary plus after getting the match