It is my understanding that Azure Table Storage stores all datetime fields as UTC AKA Zulu Time.
Currently I am in the UK 11th May 2021 at 18:10. The current TimeZone here is BST (+1:00).
If I serialise that into JSON using the RoundtripKind option
string json = JsonConvert.SerializeObject(this.syncDates, Formatting.Indented, new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind
});
It will be sent to my Web Api as
"2021-05-11T18:10:31.740582+01:00"
However when it is deserialised into the ASP NET Core controller method arguments it appears as a DateTime with DateTimeKind of Local but no longer has any Time Zone Info.
11/05/2021 18:10:31
I then write the Date into Azure Table Storage and it will be stored as UTC which is
11/05/2021 17:10:31
When I retreive the data from the web api to display it to the originating user or someone else who wants to look at their data, it is important to know the correct date and hour in relation to the user.
Should I be storing the originating Time offset\zone in a separate field and using that to convert the Date back out again?
Should I not be storing as a DateTime at all and using DateTimeOffset or is that pointless as Azure Table Storage will just convert the DTO to UTC as well?