Search code examples
javascriptjsondatestring-parsingdate-parsing

Having trouble converting string (parsed from JSON) into javascript date object


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

And I'm getting back the error:

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

Which throws the same error


Solution

  • 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.