PDA

View Full Version : Store 'type: date' fields returns altered value ('T' added) if saved?



ExtKD
10 Apr 2010, 4:10 AM
n/a

DaviBaldin
17 May 2010, 12:21 PM
Did you get rid of this?

wm003
17 May 2010, 11:51 PM
The "T" comes from some JSON Encoding mechanism. Perhaps from the server just before sending it to the client or by the "encode:true" attribute.
The basic problem is the JSON Decoding which cannot handle these "T"-Encoded Dates from the JSON Encoding back to real Javascript Date Objects.

So at the point you are setting the datefield with the appropriate value, you need to parse the Date by yourself like this:


myDateField.setValue(Date.parseDate(lastupdated.replace(/T/," "),'Y-m-d H:i:s'));

Condor
18 May 2010, 12:20 AM
See this thread (http://www.extjs.com/forum/showthread.php?73346-Reader-writer-is-not-using-the-same-date-format-!-!&p=353031#post353031).

DaviBaldin
18 May 2010, 4:00 AM
ExtKD I've lost a lot of time on this too. However, you can use this (like in your main method).

Ext.util.JSON.encodeDate = function(d) {
return d.format('"Y-m-d\\TH:i:s.000O"');
};

And you will be able to fix this issue. In my case, this is the compatible format for Java systems.

Cheers,

Davi