DateTime convert

Through swagger I send a request for a date, but why does it come wrong, can you tell what may be the error? Thanks.

public class CompletionDocumentPush : IReturn<...> {
        [ApiMember(IsRequired = true)] public DateTime? Date { get; set; }

“Date”: “2019-07-02T22:08:18.142Z”

The Date is sent over the wire in UTC which gets converted into your Local time as visible by .Kind == Local, you can convert DateTime’s to UTC with .ToUniversalTime().

But how can I turn off the conversion to Local?

If you want it in UTC, convert it with:

var utcDate = date.ToUniversalTime();

If you’re really sure you don’t want DateTime’s in LocalTime you can configure it in your AppHost with:

JsConfig.Init(new ServiceStack.Text.Config {
    SkipDateTimeConversion = true
1 Like