DateTime.IsDaylightSavingTime() Method in C#
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:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
DateTime date = new DateTime(2010, 1,
1, 4, 0, 15);
bool value = date.IsDaylightSavingTime();
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." );
}
}
|
Output:
Instance of DateTime is not within the daylight saving time range for the current time zone.
Example 2:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
DateTime date = new DateTime(1970, 1,
1, 4, 0, 15);
bool value = date.IsDaylightSavingTime();
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." );
}
}
|
Output:
Instance of DateTime is not within the daylight saving time range for the current time zone.
Reference:
Last Updated :
06 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...