0

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.