问题
C# supports different timezone id's across the globe. Please find list of time zones that are being supported by C# in below link:
https://msdn.microsoft.com/en-us/library/gg154758.aspx
The timezone id's are used in C# library functions to convert times across the timezones.
[e.g. TimeZoneInfo.ConvertTimeBySystemTimeZoneId("Hawaiian Standard Time")
]
Similarly I want support for AMERICA/MIQUELON, which is not present in the msdn list provided in above link.
Can somebody please provide workaround for this specific timezone?
回答1:
Time zone identifiers like "America/Miquelon"
and the others you listed (before editing your question) are from the IANA time zone database. You can read more in the timezone tag wiki and on Wikipedia.
Note that they are usually presented in mixed case form, rather than in all capital letters.
The easiest and best way to work with these in .NET is via the Noda Time library.
For example:
DateTimeZone tz = DateTimeZoneProviders.Tzdb["America/Miquelon"];
Instant now = SystemClock.Instance.Now;
ZonedDateTime converted = now.InZone(tz);
来源:https://stackoverflow.com/questions/30864731/iana-olson-timezone-support-in-c-sharp