Difference between UTC and GMT Standard Time in .NET

后端 未结 7 1022
臣服心动
臣服心动 2020-11-27 04:45

In .NET, the following statements return different values:

Response.Write(
  TimeZoneInfo.ConvertTime(
    DateTime.Parse("2010-07-01 5:30:00.000"),         


        
7条回答
  •  猫巷女王i
    2020-11-27 05:22

    [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!

提交回复
热议问题