TimeZoneInfo.Local Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets a TimeZoneInfo object that represents the local time zone.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

Public Shared ReadOnly Property Local As TimeZoneInfo
public static TimeZoneInfo Local { get; }

Property Value

Type: System..::.TimeZoneInfo
A TimeZoneInfo object that represents the local time zone.

Remarks

The local time zone is the time zone on the computer where the code is executing.

Important Note:

You should access the local time zone through the TimeZoneInfo..::.Local property rather than assigning the local time zone to a TimeZoneInfo object variable.

On Windows systems, the TimeZoneInfo object returned by the TimeZoneInfo..::.Local property reflects the setting of the Automatically adjust clock for daylight saving changes checkbox or the Automatically adjust clock for Daylight Saving Time checkbox in the Control Panel Date and Time application for Windows XP and Windows Vista, respectively. If the checkbox is unchecked, the cached copy of the local time zone contains no daylight saving time information. This means that:

Version Notes

XNA Framework

 When this property is used in the XNA Framework, it throws a NotSupportedException exception.

Examples

The following example retrieves a TimeZoneInfo object that represents the local time zone and outputs its display name, standard time name, and daylight saving time name.

Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
outputBlock.Text &= "Local Time Zone:" & vbCrLf
outputBlock.Text &= String.Format("   Display Name is: {0}.", localZone.DisplayName) & vbCrLf
outputBlock.Text &= String.Format("   Standard name is: {0}.", localZone.StandardName) & vbCrLf
outputBlock.Text &= String.Format("   Daylight saving name is: {0}.", localZone.DaylightName) & vbCrLf
TimeZoneInfo localZone = TimeZoneInfo.Local;
outputBlock.Text += "Local Time Zone ID:" + "\n";
outputBlock.Text += String.Format("   Display Name is: {0}.", localZone.DisplayName) + "\n";
outputBlock.Text += String.Format("   Standard name is: {0}.", localZone.StandardName) + "\n";
outputBlock.Text += String.Format("   Daylight saving name is: {0}.", localZone.DaylightName) + "\n";

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

TimeZoneInfo Class

System Namespace