C# Program to Get the DayLight Saving Information

This is a C# Program to get the daylight saving information.

Problem Description

This C# Program Gets the DayLight Saving Information.

Problem Solution

Here the information about the current year’s daylight saving changes is obtained.

Program/Source Code

Here is source code of the C# Program to Get the DayLight Saving Information. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Get the DayLight Saving Information
 */
using System;
using System.Globalization;
class Program
{
    static void Main()
    {
        TimeZone z = TimeZone.CurrentTimeZone;
        DaylightTime t = z.GetDaylightChanges(DateTime.Today.Year);
        Console.WriteLine("Start Time: {0}", t.Start);
        Console.WriteLine("Delta Time: {0}", t.Delta);
        Console.WriteLine("End Time: {0}", t.End);
        Console.ReadLine();
    }
}
Program Explanation

This C# program is used to get the DayLight saving information. The GetDaylightChanges() function indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current TimeZoneInfo object. Then the information about the current year’s daylight saving changes is obtained.

advertisement
advertisement
Runtime Test Cases
 
Start Time: 1/1/0001 12:00:00 AM
Delta Time: 00:00:00
End Time: 1/1/0001 12:00:00 AM

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.