How to get date time from this /Date(1518696376959)/
in javascript?
I have tried like this
var d = new Date("1519192874994");
How to get date time from this /Date(1518696376959)/
in javascript?
I have tried like this
var d = new Date("1519192874994");
I have tried like this var d = new Date("1519192874994");
No need to wrap it in quotes, Date
constructor will takes millisecond value (Number
)
var d = new Date(1519192874994) //Wed Feb 21 2018 11:31:14 GMT+0530 (India Standard Time)
From "/Date(1518696376959)/"
Make it
var str = "/Date(1518696376959)/";
var date = new Date( +str.match(/\d+/g)[0] ); //notice the unary plus after getting the match