HomeCSharpHow to Check if Time Zone is British Summer Time in C#?

How to Check if Time Zone is British Summer Time in C#?

In this post, let’s have a look at a simple tip to find out if the current time zone is a British Summer Time (BST) or not in C#.

How to Check if Time Zone is British Summer Time in C#?

First get the TimeZoneInfo object and then use the use the function TimeZoneInfo.IsDaylightSavingTime Method to check if it is currently Daylight saving for your Timezone.

Usually, the Day Light Savings should be false for a Greenwich Standard Time for a British Summer Time Zone.

using System;

public class DeveloperPublish
{
    public static void Main() {

        var info = TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time");
        DateTimeOffset localServerTime = DateTimeOffset.Now;
        bool isDaylightSaving = info.IsDaylightSavingTime(localServerTime);
        Console.WriteLine("Day Light Savings :" + isDaylightSaving);
        Console.ReadLine();
    }
}

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...