I have following JSON response created by Doctrine 2 as a datetime entity in server-side and encoded as JSON by zend framework`s Zend_Json::encode($stores) method:
{
"birthdate":
{"date":"2011-08-19 00:00:00","timezone_type":3,"timezone":"Europe\/Berlin"}
}
I need to create a new Date() using this JSON for my Extjs data grid but I can't figure out how to manipulate JSON response. Assuming I have a JSON store and I can access to birthdate object, new Date(birthdate.date) gives "Date {Invalid Date}".new Date("date":"2011-08-19 00:00:00") gives the same error but new Date("date":"2011-08-19") works fine. Please advice me on how to create a date object from my JSON store.
You can parse the date using the following code
Date.parseDate("2011-08-19 00:00:00", "Y-m-d h:i:s");
API Doc
As per ExtJS 4.0 the method is changed as parse
Ext.Date.parse("2011-08-19 00:00:00", "Y-m-d h:i:s")
API Doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With