Virab
July 2, 2019, 10:22pm
1
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”
}
mythz
July 2, 2019, 10:44pm
2
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()
.
Virab
July 2, 2019, 10:55pm
3
But how can I turn off the conversion to Local?
mythz
July 2, 2019, 11:02pm
4
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