PDA

View Full Version : return format of json Dates



steverc
20 Nov 2009, 8:20 PM
I have a date field via JSON in M-d-y format. It is being read and rendered (as m/d/Y) properly.

However... when the JSON is written back to the server it seems the Date is in full ISO8601 format (ie. dateFormat: 'c') even though I've explicitly stated the dateFormat to be 'Y-m-d'.

How can I make sure the JSON being sent back to the server includes only the date and not the time portion?

Note: This is using the RowEditor plugin and accompanying JSON writer.

Mike Robinson
23 Nov 2009, 8:31 AM
As far as I know, JSON output always goes out in the ISO standard-format which includes a time component. (I also pleasantly found that MS SQL Server understands this format implicitly.)

I'd say, just let it be, and deal with it if you have to on the server side. The format is absolutely consistent and is easily dealt-with by a regular expression if you need to chop-off the time. Do your reformatting, etc. on the server side once the data arrives.

Rishab
8 Jan 2010, 6:13 AM
Hi Steve,

Did you find a way to solve your problem at JavaScript end? I am facing similar issue and I am interested in solving it at javascript side.

Thanks,
Rishab

steverc
8 Jan 2010, 6:24 AM
I didn't find a way to handle this on the Ext side. Instead, I ended up adjusting for it on the server side (for my particular situation this was a Java with JSON marshalling)

Animal
8 Jan 2010, 6:38 AM
Ext.util.JSON.encodeDate = function(d) {
return "whatever";
}

Rishab
8 Jan 2010, 7:07 AM
Can we define output date format on grid store which will hold the date data as I see by default date is stored in ISO format.

Animal
8 Jan 2010, 7:19 AM
A Date is not stored in any format. A Date is a Date object.

What was the question?