C# TimeZone GetUtcOffset

Description

TimeZone GetUtcOffset returns the Coordinated Universal Time (UTC) offset for the specified local time.

Syntax

TimeZone.GetUtcOffset has the following syntax.


public abstract TimeSpan GetUtcOffset(
  DateTime time
)

Parameters

TimeZone.GetUtcOffset has the following parameters.

  • time - A date and time value.

Returns

TimeZone.GetUtcOffset method returns The Coordinated Universal Time (UTC) offset from time.

Example

The following code shows how to use TimeZone.GetUtcOffset().


/* w  ww .  ja  v a2 s .c  o  m*/
using System;
using System.Globalization;

class TimeZoneDemo
{
    static void Main( )
    {
        TimeZone localZone = TimeZone.CurrentTimeZone;
        Console.WriteLine(localZone.GetUtcOffset(DateTime.Now) );
    } 
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version