A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

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

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

0

Syntax:

    TimeSpan TimeZoneInfo.GetUtcOffset(DateTime date_time);

Parameter(s):

  • date_time: date_time to find offset from UTC time.

Return value:

This method returns the object of TimeSpan that represents offset from UTC.

 

All Answers

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

Program:

The source code to calculate the offset between the time in this time zone and UTC 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()
    {
        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);

    }
}

Output:

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

 

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now