无法将字符串(从JSON解析)转换为javascript date对象 [英] Having trouble converting string (parsed from JSON) into javascript date object
本文介绍了无法将字符串(从JSON解析)转换为javascript date对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试通过以下方式创建javasscript日期对象
I am trying to create javasscript date object in the following way
var object = {"name":"Bay Area Global Health Film Festival","start_time":"2013-07-08T19:00:00","end_time":"2013-07-08T23:45:00","timezone":"America/Los_Angeles","location":"San Francisco","id":"458415670892007","rsvp_status":"attending"}
var tempDate = date(object.start_time);
我又得到了错误:
date is not defined
我还尝试使用以下方法修剪字符串:
I have also tried trimming the string using:
var tempDate = date(object.start_time.slice(0,object.start_time.indexOf("T"));
//This yields an input of 2013-07-08
哪个会抛出相同的错误
推荐答案
尝试使用此new Date("2013-07-08T19:00:00")
.您得到的时间似乎是必需的格式,因此应该没有问题.
Try this new Date("2013-07-08T19:00:00")
. The time you are gettng seems to be in the required format so there shouldn't be issues.
这篇关于无法将字符串(从JSON解析)转换为javascript date对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文