I get the FILETIME structure in UTC from the native server (C ++). On the client side of managed (C #), I need to show it as client (!) Local time. Do I need to send server time zone information with FILETIME for this? Or is this information already contained in FILETIME in UTC?
You can convert UTC DateTime to local time using TimeZoneInfo
TimeZoneInfo
TimeZoneInfo.ConvertTimeFromUtc(YourDateTime, TimeZoneInfo.Local);
You can convert UTC DateTime to any time zone if you know the name. For instance.
TimeZoneInfo.ConvertTimeFromUtc(YourDateTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
create a class public class TimeConverter { public static DateTime ConvertToLocalTime(DateTime utcTime, string timeZoneId) { if (string.IsNullOrEmpty(timeZoneId)) { return utcTime; } return TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utcTime, timeZoneId); } } In controller use TimeConverter TimeConverter.ConvertToLocalTime(Date, yourTimeZone));
I don't know what your structure is, but if you can convert it to a standard time string, the DateTime class will parse it. Then just use the ToLocalTime method.
DateTime time = DateTime.Parse(FILETIME.ToString()); time.ToLocalTime();