0

There's a great thread here: How do I format a Microsoft JSON date? that shows how to parse an ASP.NET formatted JSON date:

/Date(1224043200000)/

... back into an actual JavaScript Date object. However, it doesn't show how to go the other way. So, given a date - how do I go from:

new Date() // to /Date(1224043200000)/ ???

2 Answers 2

3
var d = ['/Date(', new Date().getTime(), ')/'].join('');
Sign up to request clarification or add additional context in comments.

Comments

2
var t = new Date();
t.getTime();

1 Comment

Well, that gets you the number of milliseconds corresponding to the Date t. I suppose you can take that and wrap it in a /Date( )/ string.

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.