0

Why OData returns Json DataTime values in UTC (like "2019-02-15T17:29:38.583Z"), while an endpoint that just returns an entity, the datetime misses the 'Z' (like "2019-02-15T19:19:04.783"). There is no custom formmating or serialization for Json serializer, there is no use of settings like DateTimeZoneHandling.

DateTime objects are save in DB as UTC, in C# code, the DTO contains those values correctly and the Kind is unespecified as in OData as in entity.

Why is this behavior? I need to Json output returning datetimes as UTC (with Z). Any explanation and setting for achiving this is welcome.

Thanks.

Framework version: 4.5.2

Edgar L
  • 3
  • 4
  • When it misses the Z, does it include something like `+0900` (or whatever timezone you're in)? I'm curious if it's treating the date as local time or universal. – ProgrammingLlama Feb 19 '19 at 00:47
  • Possible duplicate of [Where's the DateTime 'Z' format specifier?](https://stackoverflow.com/questions/833102/wheres-the-datetime-z-format-specifier) – andercruzbr Feb 19 '19 at 00:48
  • There is no +0900 – Edgar L Feb 19 '19 at 01:46
  • The question is related more to json serialization, nothing to do with string parsing because none of it happends in my code. The question is why OData does serialize datetime different to entity web api and what can I do about this. – Edgar L Feb 19 '19 at 13:43

0 Answers0