The IDs and data used with TimeZoneInfo are platform dependent:
- On Windows, the IDs are the Microsoft time zone identifiers, as used with the
tzutil.exe command, Win32 APIs, and are sourced from the Registry.
- Example:
"Mountain Standard Time"
- On Mac OSX, Linux, and other non-Windows platforms, the IDs are IANA time zone identifiers, as used by the
TZ environment variable, timedatectl, sudo dpkg-reconfigure tzdata, sudo systemsetup -settimezone timezone, and other platform-specific utilities. The data is sourced from the IANA tz database.
- Example:
"America/Denver"
Thus you can change your code to the following, which will run on Linux and Mac OSX.
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("America/Denver");
If you cannot change the identifiers used in your application, or are designing your application to be cross-platform and need to work with both sets of identifiers, then use my TimeZoneConverter library:
// Either of these will work on any platform
TimeZoneInfo tzi = TZConvert.GetTimeZoneInfo("Mountain Standard Time");
TimeZoneInfo tzi = TZConvert.GetTimeZoneInfo("America/Denver");
See also the "Time Zone Databases" section of the timezone tag wiki.