Hi,

The below TimeZone code returns the following string: "(GMT-05:00) Eastern Time (US & Canada)"

TimeZoneInfo FromZoneID = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

What I wonder how it is possible to do is how I create the TimzeZoneInfo object by using the string
directly. I have tried this but it doesn´t work. I beleive I do something wrong?

TimeZoneInfo FromZoneID = TimeZoneInfo.FromSerializedString("(GMT-05:00) Eastern Time (US & Canada)");
using System;
class Program
{
    static void Main()
    {
        TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
        string serialized = info.ToSerializedString();
        Console.WriteLine("serialized:      {0}", serialized);
        TimeZoneInfo deserialized = TimeZoneInfo.FromSerializedString("Eastern Standard Time;-300;(UTC-05:00) Eastern Time (US & Canada);Eastern Standard Time;Eastern Daylight Time;[01:01:0001;12:31:2006;60;[0;02:00:00;4;1;0;];[0;02:00:00;10;5;0;];][01:01:2007;12:31:9999;60;[0;02:00:00;3;2;0;];[0;02:00:00;11;1;0;];];");
        Console.WriteLine("deserialized:      {0}", deserialized);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.