Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 334
frankadelic Avatar asked Feb 18 '10 21:02

frankadelic


People also ask

Is UTC a time zone or format?

The Universal Time Coordinated is a coordinated time scale. It is maintained by the Bureau International des Poids et Mesures (BIPM), which is also known as the "Z time" or "Zulu Time. " The UTC time plays a vital role because other time zones depend on it.

What is UTC time programming?

Universal Coordinated Time (UTC) is the basis for modern timekeeping. Among other things, it provides a common baseline for converting between incremental and local time. The time zone offset for UTC is 0. UTC is often indicated in field-based formats using Z .


1 Answers

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.

like image 103
Hans Passant Avatar answered Oct 05 '22 06:10

Hans Passant