Convert server UTC time to client local time

vkrzv picture vkrzv · Dec 23, 2011 · Viewed 11.1k times · Source

I get from server native (C++) application a FILETIME structure in UTC format. On the managed (C#) client side I need to show it as client(!) local time. Do I need along with FILETIME transfer information about server time zone to accomplish this? Or such information already contains in FILETIME in UTC format?

Answer

dknaack picture dknaack · Dec 23, 2011

Description

You can convert a UTC DateTime to local Time using TimeZoneInfo

Sample

TimeZoneInfo.ConvertTimeFromUtc(YourDateTime, TimeZoneInfo.Local);

You can convert a UTC DateTime to any timezone, if you know the name. For example.

TimeZoneInfo.ConvertTimeFromUtc(YourDateTime, 
                TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

More Information