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
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.

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
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.