C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method)

This article is a very important article. I mean in this C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method) we are going to know very clearly about this. We hope you like this article. Please comment if you liked this article.

C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method)

C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method)

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        DateTime ambiguousTime;

        TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
        TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("UTC");

        ambiguousTime = new DateTime(2007, 11, 4, 1, 0, 0);

        if (timeZone1.IsAmbiguousTime(ambiguousTime))
            Console.WriteLine("Time is ambiguous");
        else
            Console.WriteLine("Time is not ambiguous");

        if (timeZone2.IsAmbiguousTime(ambiguousTime))
            Console.WriteLine("Time is ambiguous");
        else
            Console.WriteLine("Time is not ambiguous");
    }
}
Time is ambiguous
Time is not ambiguous
Press any key to continue . . .

Final Words

C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method) We have clearly identified the information you need through the article. If in doubt please let us know your doubts via the comment box Thank you.

Hi, I'm Selva a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment