Difference between UTC and GMT Standard Time in .NET

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


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 HKLMSOFTWAREMicrosoftWindows NTCurrentVersionTime ZonesGMT Standard Time. You'd better stick with UTC.


[I am really just backing up Hans Passant's answer]

There seems to me to be a confusion over the use of the term "GMT" which seems to be used to mean "Greenwich Mean Time" and also the timezone used in the UK/Ireland - which flips between GMT in winter and British Summer time in summer and doesn't seem to have a well defined name in its own right!

To confuse things even more, I ran the sample code from the MSDN docs for TimeZoneInfo.GetSystemTimeZones and looked at the output.

I was very surprised to see the following definition of the "GMT Standard Time" timezone

ID: GMT Standard Time
   Display Name:  (UTC) Dublin, Edinburgh, Lisbon, London
   Standard Name:                       GMT Standard Time
   Daylight Name:                       GMT Daylight Time   ***Has Daylight Saving Time***
   Offset from UTC:                       0 hours, 0 minutes
   Number of adjustment rules:                          1
   Adjustment Rules:
      From 01/01/0001 00:00:00 to 31/12/9999 00:00:00
      Delta: 01:00:00
      Begins at 01:00 on Sunday of week 5 of March
      Ends at 02:00 on Sunday of week 5 of October

It seems (at least to me) that whoever was in charge of defining timezones in Microsoft has really muddied the waters even further here.

They obviously wanted to describe the timezone in use in UK/Ireland but they gave it an ID that included the terms "GMT" and UTC in the ID and the display name. I feel fairly confident that this timezone definition (whatever it should be called) is not UTC. It may have times that are very similar to UTC for half of the year but that is all!


The difference is as follows:

  • Greenwich Mean Time (GMT) is a term originally referring to mean solar time at the Royal Observatory in Greenwich, London. whereas
  • Coordinated Universal Time (UTC) (French: Temps Universel Coordonné) is a time standard based on International Atomic Time (TAI) with leap seconds added at irregular intervals to compensate for the Earth's slowing rotation
  • Day Light Saving Time (DST) on the other hand is advancing clocks To and for with season changes, To make max use of day light.

    "It is observed in many countries but not all" . It might be variable, as last summer some countries like Pakistan, decided to bring back clocks a month later than they normally do.

  • World Time Zones is a good resource for up-to date time information around the globe.

  • Hope this helps

    链接地址: http://www.djcxy.com/p/4994.html

    上一篇: 用C#计算相对时间

    下一篇: UTC和GMT标准时间在.NET中的区别