Remember the custom choice of TimeZoneInfo in a cookie, a property to use with C #?

I have a DropDownList control that populates the TimeZones clock:

ReadOnlyCollection<TimeZoneInfo> tzCollection; tzCollection = TimeZoneInfo.GetSystemTimeZones(); 

Now I want to add an option to remember the user's previous choice in a persistent cookie, but I can’t figure out which parameter to use for this: I thought to use a time offset from GMT / UTC, but there could be several time zones in the list with the same offset . And using the TimeZoneInfo.Id property also seems unpleasant to me, because it is represented by a descriptive string, such as "Standard Pacific Time", which can be a problem for localization (in the case of foreign languages).

So, any suggestions that I will use?

+4
source share
1 answer

TimeZoneInfo.Id is exactly the value to use. Then you can get it using TimeZoneInfo.FindSystemTimeZoneById .

Despite the fact that this looks like a localizable string, in fact it is not - I believe that you will get the same result no matter what culture you use. (This is not clear, to be honest - it’s hard for me to convince any property to give non-English results in test programs.)

+3
source

All Articles