javascript - Working with Parse.com dates - Stack Overflow

I have dates stored using Parse backend.I retrieve them using JSON.stringify.Everything is working

I have dates stored using Parse 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 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!

I have dates stored using Parse. 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. 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!

Share asked Jun 6, 2013 at 22:26 hypermilerhypermiler 2,1074 gold badges21 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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);

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745049705a4608311.html

相关推荐

  • javascript - Working with Parse.com dates - Stack Overflow

    I have dates stored using Parse backend.I retrieve them using JSON.stringify.Everything is working

    8小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信