When designing a service that returns JSON to the browser (or server side JS), what is the "best" format for encoding dates in the resulting JSON response?
The data property should:
Returning the number of milliseconds since 1 January 1970 00:00:00 UTC seems like it would be the best option but is not particularly human readable when looking at the raw JSON.
What's preferred in your experience and why?
Personally I'd go with ISO 8601 (e.g. 2011-01-13T14:09Z).
It's well supported by virtually every programming language around, it's fairly easily human readable and, if you absolutely have to roll your own parser/formatter, it's fairly easy to deal with there too. It also has the sortable property you wanted.
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