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

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...