Reputation: 131
I created some funtion but how to convert string timestamp to date format for the given variabe.
var data="/Date(1424853425207)/";
data=data.parse(data);
consoe.log(data);
But enabe show the date for the above variable
Upvotes: 0
Views: 2601
Reputation: 47099
You can fetch the timestamp using regex and then cast to a number so it can be used to create a new instance of Date
:
var data = "/Date(1424853425207)/";
var timestamp = +data.replace(/\/Date\((.*?)\)\//g, '$1');
var date = new Date(timestamp);
console.log(date); // Wed Feb 25 2015 09:37:05 GMT+0100
Upvotes: 1