I have saved a utc datetime in database and I have to display the datetime value in local time of the user`s country setting.
There are multiple ways to get a local datetime from a utc datetime:
var dateTimeLocal = TimeZone.CurrentTimeZone.ToLocalTime(dateTimeUtc);
var dateTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time"));
var dateTimeLocal = dateTimeUtc.ToLocalTime())
It seems most time there is a timezone involved to get the local date because the timezone determines the offset in hours to the local datetime.
When I have a user.country = "SE"
(Sweden), how do you programatically determine the timezone to convert the correct local datetime from the utc datetime?
Or is it enough to set the CurrentThread Culture/UiCulture to "sv-SE" and the timezone is automatically set by the .NET framework?