ServiceStack and DateTime fields

Hi,

We have an Angular app talking to a Service Stack API (with .Net core). Our database stores some date fields as UTC. The Angular app converts local dates to UTC using moment.js and sends these date values to the API, but we noticed that when it hits the service, it is not UTC anymore.

We have not seen this issue with our mobile apps that use JsonServiceClient.

For e.g. if the Angular app sends the date in the format “2019-05-11T14:00:00Z”, it does not work at the API. However, a format like “2019-05-10 02:33:30” works as expected.

I noticed that there are some JsConfig settings like AssumeUtc, AlwaysUseUtc, SkipDateTimeConversion, AppendUtcOffset etc.

Could you please explain when these need to be used and why the APIs work differently when using JsonServiceClient vs. From Angular?

Really appreciate it.

Thanks,
Leeny

By default ServiceStack’s serializes DateTime as UTC over the wire but converts them to Local Time, you can use SkipDateTimeConversion to opt-out of this behavior.

Thanks for the explanation. I have been trying out the various options and it all makes sense, except for one combination. For e.g.

JSConfig.AssumeUTC is true

If the date value is sent as ‘2019-05-11 14:00:00’ → This is received at the API with Kind as Unspecified. I thought that because AssumeUTC is true, the date is assumed to be UTC and would still be converted to Local at the API.
However, the date value remains as ‘2019-05-11 14:00:00’.

Thanks!