I have a DropDownList control that is populated with TimeZones from calling:
ReadOnlyCollection<TimeZoneInfo> tzCollection;
tzCollection = TimeZoneInfo.GetSystemTimeZones();
Now I want to add an option to remember a previous user selection in a persistent cookie but I can’t figure out which parameter to use for that: I thought to use the time offset from GMT/UTC, but there might be several time zones in the list with the same offset. And using the TimeZoneInfo.Id property also seems bad to me because it is represented by descriptive string such as “Pacific Standard Time”, which may pose a problem for localization (in case of foreign languages.)
So any suggestions what shall I use?
TimeZoneInfo.Idis precisely the value to use. You can then fetch it withTimeZoneInfo.FindSystemTimeZoneById.Even though it looks like a localizable string, it really isn’t – I believe you’ll get the same result whatever culture you’re using. (It’s not clear to be honest – I’m finding it hard to persuade any of the properties to give non-English results in test programs.)