On Mon, 30 Jan 2012, silvioprog wrote:
Hello,
What the best way to save a datetime value in a JSON object?
1 - JSONObj['datetime'].AsString := DateTimeToStr(Now); // No no no ... :/
2 - JSONObj['datetime'].AsString := DateTimeToJS(Now); // Result:
\/Date(1240718400000)\/, So: { "datetime": "\/Date(1240718400000)\/" }
// Hm... :|
1 or 2, or other?
Is there a native function to convert it? From JSON to DateTime and
from DateTime to JSON?
Strictly speaking, JSON does not know a date/time object.
So, how to write it depends on the client application.
ExtJS uses by default an ISO format (and expects one as of ExtJS 4):
1995-07-18T17:21:28-02:00
Which seems the best to do anyway.
Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus