locked
Handling DateTime JSON RRS feed

  • Question

  • User1122355199 posted

    Hello everyone and thanks for your help in advance.  I have a web api that returns several datetime columns within the returned JSON.  Format example is 2016-07-15 11:01:54.210.  My consuming page needs to format the date in mm/dd/yyyy format.  My question is should I convert the datetime prior to the return of the data, or should I format the date client side and how do I do it?  Any help would be appreciated.

    Saturday, August 6, 2016 2:42 AM

Answers

  • User-474980206 posted

    as its not a valid ISO format which would be: "2016-07-15T11:01:54.210Z" (UTC), dropping the time it becomes valid. (.net does not support ISO dates, but newtonsoft does support ISO dates). 

    note: "07/15/2016 11:01:54" is a  valid local date format (assumes locale == US)

    note 2: "2016-07-15" is a valid ISO date and impies midnight zulu time or "Thu Jul 14 2016 17:00:00 GMT-0700 (PDT)" in my timezone.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 6, 2016 9:30 PM