Compartilhar via


SetTimeZoneInformation (Compact 2013)

3/28/2014

This function sets the current time-zone parameters. These parameters control translations from UTC to local time.

Syntax

BOOL SetTimeZoneInformation(
  const TIME_ZONE_INFORMATION* lpTimeZoneInformation
);

Parameters

  • lpTimeZoneInformation
    [in] Pointer to a TIME_ZONE_INFORMATION structure that contains the time-zone parameters to set.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

SetTimeZoneInformation does not save the newly written data into the persistent registry. To write the data permanently, you need to make the following call: RegFlushKey(HKEY_LOCAL_MACHINE). For more information, see RegFlushKey.

All translations between UTC and local time are based on the following formula:

UTC = local time + bias

The bias is the difference, in minutes, between UTC and local time.

SetTimeZoneInformation changes the clock to reflect the change in bias. However, GetLocalTime may not immediately reflect changes made from non-DST zones to DST zones (and vice-versa). Changes will appear once the system time service properly adjusts the clock based on the new DST status.

The Dynamic DST service updates the time zone information based on the Id of the time zone.  SetTimeZoneInformation does not specify the Id of time zone, causing the Dynamic DST service to stop functioning properly.  You should use

SetTimeZoneInformationByID instead of SetTimeZoneInformation.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

Time Functions
GetLocalTime
GetSystemTime
GetTimeZoneInformation
TIME_ZONE_INFORMATION

Other Resources

RegFlushKey
Timer Driver Reference