asp.net.ph

TimeZone.GetUtcOffset Method

System Namespace   TimeZone Structure


Returns the coordinated universal time ( UTC ) offset for the specified local time.

[ VB ]
Public MustOverride Function GetUtcOffset ( _
   time As DateTime _
) As TimeSpan

[ C# ]
public abstract TimeSpan GetUtcOffset (
   DateTime time
)

[ C++ ]
public:
virtual TimeSpan GetUtcOffset (
   DateTime time
) abstract

[ JScript ]
public abstract function GetUtcOffset (
   time : DateTime
) : TimeSpan

Parameters

time
The local date and time.

Return Value

The UTC offset from time, measured in ticks.

Remarks

Coordinated universal time ( UTC ) was previously known as Greenwich Mean Time (GMT). Local time is the date and time on the computer you are using. Offset is the difference between local time and UTC. That is:

local time = UTC + offset

time must be in the Gregorian calendar and the time zone represented by this instance. If time is in daylight saving time, this method returns the UTC offset to the daylight saving time zone. This method obtains the daylight saving time rule from the system.

For example, in the United States Pacific Standard time zone, which has -8 hours of offset, GetUtcOffset ( new DateTime ( 1999, 1, 1 ) ) returns -288000000000.

Example

The following example gets the value returned by the GetUtcOffset method for the current time zone set on the Web server.

 Show me 

The following examples show how to determine and set the current local time of a user's browser based on the current time zone setting on the Web server.

This is done basically by calling a client-side JavaScript function to determine the current browser's UTC offset based on the time zone setting of the browser, and then calculating the current browser's local time from the UTC time derived from the time zone setting of the server.

TimeZone.ToUniversalTime Example
Run Sample | View Source
Localization Resource Fallback
Run Sample | View Source
See Also

TimeZone Members   CurrentTimeZone Property   ToUniversalTime Method Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note