Use the string.prototype.match
method:
var str = "/Date(1396505647431)/";
-
str.match(/Date\(\d+\)/)[0]
gives"Date(1396505647431)"
-
var time = new Date(+str.match(/\d+/)[0])
givesThu Apr 03 2014 11:44:07 GMT+0530 (India Standard Time)
-
time.toLocaleTimeString()
gives"11:44:07 AM"
solved How to extract a string from a line of characters? [closed]