考虑日光,计算不同时区的2个不同时间之间的时差

时间:2021-10-05 21:31:46

Consider I have 2 times which are for different countires:

考虑我有两次针对不同的countires:

"2013/02/11 13:20:44" (Tehran possibly UTC+3:30 or UTC+2:30 due to day light saving)
"2013/02/11 15:20:44" (Abu Dhabi possibly UTC+4:00 or UTC+3:00 due to day light saving)

Question1: How can I accurately convert these times to Utc?

问题1:如何准确地将这些时间转换为Utc?

I want to mention that the day light saving is not a fixed information and may vary time to time and country to country.

我想提一下,节省日照不是一个固定的信息,可能会随着时间和国家而变化。

For example in 2010 Iran had not day light savings for some political reasons.

例如,2010年,由于某些政治原因,伊朗没有节省日光。

Question2: Is there some trust-able place or web service with this information?

问题2:这些信息是否有一些可信赖的地方或网络服务?

2 个解决方案

#1


3  

For .net application Time Zone information updates with Windows updates, so if you server always have latest updates, you won't have problems with time zones.

对于.net应用程序时区信息更新与Windows更新,因此如果您的服务器始终有最新的更新,您将不会遇到时区问题。

And if you need to convert time, you can use TimeZoneInfo class:

如果您需要转换时间,可以使用TimeZoneInfo类:

TimeZoneInfo.ConvertTime(new DateTime(2005, 6, 1), TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time"), TimeZoneInfo.Utc)

And if you need to, you can get AdjestmentRules for time zones:

如果需要,您可以获得时区的AdjestmentRules:

TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time").GetAdjustmentRules();

#2


0  

You could try using Noda Time

您可以尝试使用Noda Time

More detailed information can be found in this thread

更多详细信息可以在这个主题中找到

#1


3  

For .net application Time Zone information updates with Windows updates, so if you server always have latest updates, you won't have problems with time zones.

对于.net应用程序时区信息更新与Windows更新,因此如果您的服务器始终有最新的更新,您将不会遇到时区问题。

And if you need to convert time, you can use TimeZoneInfo class:

如果您需要转换时间,可以使用TimeZoneInfo类:

TimeZoneInfo.ConvertTime(new DateTime(2005, 6, 1), TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time"), TimeZoneInfo.Utc)

And if you need to, you can get AdjestmentRules for time zones:

如果需要,您可以获得时区的AdjestmentRules:

TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time").GetAdjustmentRules();

#2


0  

You could try using Noda Time

您可以尝试使用Noda Time

More detailed information can be found in this thread

更多详细信息可以在这个主题中找到