C# Program to Determine Given Date and Time Is Daylight Saving Time or Not (Timezoneinfo.isdaylightsavingtime() Method)

You are currently viewing C# Program to Determine Given Date and Time Is Daylight Saving Time or Not (Timezoneinfo.isdaylightsavingtime() Method)

C# program to determine given date and time is daylight saving time or not (TimeZoneInfo.IsDaylightSavingTime() Method)

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

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        DateTime dateTime1;
        TimeZoneInfo time_zone = TimeZoneInfo.Local;

        dateTime1 = new DateTime(2020, 2, 10, 10, 10, 10);

        if (time_zone.IsDaylightSavingTime(dateTime1))
            Console.WriteLine("It is daylight saving time");
        else
            Console.WriteLine("It is not daylight saving time");
    }
}
It is not daylight saving time
Press any key to continue . . .

Ranjith Kumar

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

Leave a Reply