Q:

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

belongs to collection: C# TimeZoneInfo Class Programs

0

Syntax:

    bool TimeZoneInfo. IsDaylightSavingTime (DateTime date_time);

Parameter(s):

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

Exception(s):

  • System.ArgumentException
  •  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

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

Output:

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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# TimeZoneInfo Class Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< C# program to get the ambiguous time offsets (Time...