Gets a TimeZoneInfo object that represents the local time zone.
Assembly: mscorlib (in mscorlib.dll)
The local time zone is the time zone on the computer where the code is executing.
You should always access the local time zone through the property rather than assigning the local time zone to a TimeZoneInfo object variable. This prevents the TimeZoneInfo object variable from being invalidated by a call to the ClearCachedData method.
The TimeZoneInfo object returned by the 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:
The local time zone's GetAdjustmentRules method returns an array whose length is zero.
The local time zone's SupportsDaylightSavingTime property returns false.
All calls to IsDaylightSavingTime with individual local times return false.
This is not true, however, if a reference to the local time zone is retrieved using the FindSystemTimeZoneById method.Notes to Callers
In converting dates and times, Windows XP recognizes only the current adjustment rule, which it applies to all dates, including down-level dates (that is, dates that are earlier than the starting date of the current adjustment rule). On Windows XP, to prevent local date and time information provided by the object from diverging from the date and time information displayed in the system tray, the TimeZoneInfo object returned by the property also applies the current adjustment rule to down-level dates. Applications running on Windows XP that require historically accurate local date and time calculations must work around this behavior by using the FindSystemTimeZoneById method to retrieve a TimeZoneInfo object that corresponds to the local time zone.
The following example provides an illustration for a Windows XP system in the U.S. Pacific Time zone. Because the first three method calls all use the local time zone returned by the property, they apply the current time zone adjustment rule (which went into effect in 2007) to a date in 2006. The current adjustment rule provides for the transition to daylight saving time to occur on the second Sunday of March; the previous rule, which was in effect in 2006, provided for the transition to daylight saving time to occur on the first Sunday of April. Only the fourth method call, which uses the FindSystemTimeZoneById method to retrieve the local time zone, accurately performs this historical date and time conversion.
.NET FrameworkSupported in: 4.5.2, 4.5.1, 4.5, 4, 3.5
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.