Difference between UTC and GMT Standard Time in .NET

frankadelic picture frankadelic · Feb 18, 2010 · Viewed 59.8k times · Source

In .NET, the following statements return different values:

Response.Write(
  TimeZoneInfo.ConvertTime(
    DateTime.Parse("2010-07-01 5:30:00.000"),
    TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"),
    TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time"))
  );
// displays 7/1/2010 1:30:00 PM

..and this...

Response.Write(
  TimeZoneInfo.ConvertTime(
    DateTime.Parse("2010-07-01 5:30:00.000"),
    TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"),
    TimeZoneInfo.FindSystemTimeZoneById("UTC"))
  );
// displays 7/1/2010 12:30:00 PM

Why is this? I thought UTC and GMT Standard Time are equivalent.


Update

Upon further testing, I find that the following appear to be equivalent:

"UTC"

"Greenwich Mean Time"

"Morocco Standard Time"

Whereas, the following is different during summer months:

"GMT Standard Time"

Perhaps my question should be, why are "Greenwich Mean Time" and "GMT Standard Time" different?

End Update

Answer

Hans Passant picture Hans Passant · Feb 18, 2010

GMT does not adjust for Daylight saving time (DST). You can hear it from the horse's mouth on this web site.

Add this line of code to see the source of the problem:

  Console.WriteLine(TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time").SupportsDaylightSavingTime);

Output: True.

This is not a .NET problem, it is Windows messing up. The registry key that TimeZoneInfo uses is HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\GMT Standard Time. You'd better stick with UTC.