在 .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
..还有这个...
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
这是为什么?我认为 UTC 和 GMT 标准时间是等价的.
Why is this? I thought UTC and GMT Standard Time are equivalent.
更新
经过进一步测试,我发现以下似乎是等效的:
Upon further testing, I find that the following appear to be equivalent:
UTC"
格林威治标准时间"
摩洛哥标准时间"
然而,夏季月份的情况有所不同:
Whereas, the following is different during summer months:
格林威治标准时间"
也许我的问题应该是,为什么是格林威治标准时间"?和GMT 标准时间"不一样?
Perhaps my question should be, why are "Greenwich Mean Time" and "GMT Standard Time" different?
结束更新
GMT 不 调整 夏令时 (DST).您可以在这个 网站上听到马嘴里的声音.
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);
输出:真.
这不是 .NET 问题,而是 Windows 搞砸了.TimeZoneInfo 使用的注册表项是 HKLMSOFTWAREMicrosoftWindows NTCurrentVersionTime ZonesGMT 标准时间.你最好坚持使用 UTC.
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.
这篇关于.NET 中 UTC 和 GMT 标准时间之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!