Convert UTC/GMT time to local time

前端 未结 11 1007
情深已故
情深已故 2020-11-22 04:39

We are developing a C# application for a web-service client. This will run on Windows XP PC\'s.

One of the fields returned by the web service is a DateTime field. Th

11条回答
  •  被撕碎了的回忆
    2020-11-22 05:31

    In answer to Dana's suggestion:

    The code sample now looks like:

    string date = "Web service date"..ToString("R", ci);
    DateTime convertedDate = DateTime.Parse(date);            
    DateTime dt = TimeZone.CurrentTimeZone.ToLocalTime(convertedDate);
    

    The original date was 20/08/08; the kind was UTC.

    Both "convertedDate" and "dt" are the same:

    21/08/08 10:00:26; the kind was local

提交回复
热议问题