0

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)");

Edited by Darth Vader

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by BobS0327
0
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);
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.