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

C# TimeZoneInfo.IsDaylightSavingTime() Method: Here, we are going to learn how to determine given date and time is daylight saving time or not in C#.Net?
Submitted by Nidhi, on May 20, 2021

The IsDaylightSavingTime() method of TimeZoneInfo class is used to check whether a given date and time falls in the range of daylight saving time for the current TimeZoneInfo object's time zone.


    bool TimeZoneInfo. IsDaylightSavingTime (DateTime date_time);


  • date_time: A date and time.

Return value:

This method returns a boolean value if the given date-time is daylight saving time then it returns true otherwise it returns false.


  • System.ArgumentException


The source code to determine given date and time is daylight saving time or not is given below. The given program is compiled and executed successfully.

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");
            Console.WriteLine("It is not daylight saving time");


It is not daylight saving time
Press any key to continue . . .

C# TimeZoneInfo Class Programs »


What's New (MCQs)

Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.