2

I have dates stored using Parse.com backend. I retrieve them using JSON.stringify. Everything is working fantastic except for dates. I need to convert them to JavaScript dates. I understand that Parse.com stores dates in ISO 8601 format preceded by characters as in this example:

{"__type":"Date","iso":"2013-05-07T00:00:00.000Z"}

Could sure use some help on trying to convert above to standard JavaScript date. Thanks!

2 Answers 2

8

The iso8601 isn't an issue: see JavaScript Date ISO8601

As for getting the item out, don't use JSON.stringify, just access the part you need:

var d = {"__type":"Date","iso":"2013-05-07T00:00:00.000Z"};
d = new Date(d.iso);
Sign up to request clarification or add additional context in comments.

1 Comment

OMG !!!! it works! I've been working on this all day. Tested it. Works great. Thanks Dave
0

For those who dont know how to get the date and the time from an input (Works in chrome, opera and safari) HTML code

<input type="date" id="thedate">
<input type="time" id="thetime">

Javascript code

var a = document.getElementById("thedate").value;
var b = document.getElementById("thetime").value;


x = a + 'T' + b + '+02:00'; //the +02:00 is because i live in Greece and we are +02:00 GMT! Choose your own.
var d = {"__type":"Date","iso":x};
d = new Date(d.iso);

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.