C# program to calculate the offset between the time in this time zone and UTC (TimeZoneInfo.GetUtcOffset() Method)

Sometimes we get frustrated if we do not get the information we need in some articles. But this article has all the information you need when you read C# program to calculate the offset between the time in this time zone and UTC (TimeZoneInfo.GetUtcOffset() Method). Read patiently and understand.

C# program to calculate the offset between the time in this time zone and UTC (TimeZoneInfo.GetUtcOffset() Method)

C# program to calculate the offset between the time in this time zone and UTC (TimeZoneInfo.GetUtcOffset() Method)

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        TimeZoneInfo cst;
        TimeZoneInfo utc;
        
        DateTime time;
        TimeSpan offset;

        time = new DateTime(2020, 1, 1, 12, 30, 30);
        cst = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
        utc = TimeZoneInfo.Utc;


        offset = utc.GetUtcOffset(time);
        Console.WriteLine("UTC Time Offset: "+offset);

        offset = cst.GetUtcOffset(time);
        Console.WriteLine("CST Time Offset: "+offset);

    }
}
UTC Time Offset: 00:00:00
CST Time Offset: -06:00:00
Press any key to continue . . .

Final Words

We hope the C# program to calculate the offset between the time in this time zone and UTC (TimeZoneInfo.GetUtcOffset() Method) article helped you in some way. And let us know if you have any doubts. Thanks

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment