DateTime.IsDaylightSavingTime() Method in C# - GeeksforGeeks

06 Feb, 2019
This method is used to indicate whether this instance of DateTime is within the daylight saving time range for the current time zone.
Syntax: public bool IsDaylightSavingTime ();
Return Value: This method returns true if the value of the Kind property is Local or Unspecified and the value of this instance of DateTime is within the daylight saving time range for the local time zone and false if Kind is Utc.
Below programs illustrate the use of DateTime.IsDaylightSavingTime() Method:
Example 1:
// C# program to demonstrate the// DateTime.IsDaylightSavingTime()// Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(2010, 1,                                1, 4, 0, 15);          // getting Typecode of date        // using IsDaylightSavingTime() method;        bool value = date.IsDaylightSavingTime();          // checking the condition        if (value)            Console.WriteLine("Instance of DateTime is within the"                               + " daylight saving time range for"+                                        " the current time zone.");          else            Console.WriteLine("Instance of DateTime is not within the"                              + " daylight saving time range for the "+                                                  "current time zone.");    }}
Instance of DateTime is not within the daylight saving time range for the current time zone.
Example 2:
// C# program to demonstrate the// DateTime.IsDaylightSavingTime()// Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(1970, 1,                                 1, 4, 0, 15);          // getting Typecode of date        // using IsDaylightSavingTime() method;        bool value = date.IsDaylightSavingTime();          // checking the condition        if (value)            Console.WriteLine("Instance of DateTime is within the"                              + " daylight saving time range for "+                                         "the current time zone.");          else            Console.WriteLine("Instance of DateTime is not within the"                              + " daylight saving time range for the "+                                                 "current time zone.");    }}
Instance of DateTime is not within the daylight saving time range for the current time zone.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.isdaylightsavingtime?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#