SystemTimeToTzSpecificLocalTime Function
SystemTimeToTzSpecificLocalTime Function

Converts a time in Coordinated Universal Time (UTC) to a specified time zone's corresponding local time.

Syntax

BOOL WINAPI SystemTimeToTzSpecificLocalTime(
  __in_opt  LPTIME_ZONE_INFORMATION lpTimeZone,
  __in      LPSYSTEMTIME lpUniversalTime,
  __out     LPSYSTEMTIME lpLocalTime
);


Parameters

lpTimeZone [in, optional]

A pointer to a TIME_ZONE_INFORMATION structure that specifies the time zone of interest.

If lpTimeZone is NULL, the function uses the currently active time zone.

lpUniversalTime [in]

A pointer to a SYSTEMTIME structure that specifies the UTC time to be converted. The function converts this universal time to the specified time zone's corresponding local time.

lpLocalTime [out]

A pointer to a SYSTEMTIME structure that receives the local time.

Return Value

If the function succeeds, the return value is nonzero, and the function sets the members of the SYSTEMTIME structure pointed to by lpLocalTime to the appropriate local time values.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The SystemTimeToTzSpecificLocalTime function takes into account whether daylight saving time (DST) is in effect for the local time to which the system time is to be converted.

The SystemTimeToTzSpecificLocalTime function may calculate the local time incorrectly under the following conditions:

  • The time zone uses a different UTC offset for the old and new years.
  • The UTC time to be converted and the calculated local time are in different years.

Examples

For an example, see Retrieving the Last-Write Time.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See Also

GetSystemTime
GetTimeZoneInformation
System Time
SYSTEMTIME
Time Functions
TIME_ZONE_INFORMATION
TzSpecificLocalTimeToSystemTime

Send comments about this topic to Microsoft

Build date: 11/19/2009

Community Content

vb.net syntax
Added by:dmex
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function SystemTimeToTzSpecificLocalTime(ByVal lpTimeZoneInformation As IntPtr, ByRef lpUniversalTime As SYSTEMTIME, ByRef lpLocalTime As SYSTEMTIME) As Long End Function
C# syntax
Added by:dmex
[DllImport("kernel32.dll", SetLastError=true)]
private static extern long SystemTimeToTzSpecificLocalTime(IntPtr lpTimeZoneInformation, ref SYSTEMTIME lpUniversalTime, ref SYSTEMTIME lpLocalTime);
Possible error in File Time description
Added by:JohnHerbster
The first sentence (copied here) of the description of _File Times_ really disturbs me:
"A file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC). The system records file times when applications create, access, and write to files."
Just for the MSDN author's information, UTC time uses constant length seconds. (http://en.wikipedia.org/wiki/Coordinated_Universal_Time)
So who knows how many UTC 100-nanosecond intervals have elapsed since 12:00 A.M. January 1, 1601? How ever many there are, the number is not likely to be the number of UT1 100-nanosecond intervals during the same period. And if the author made a mistake there, I would suggest checking the "12:00 A.M." time. Did maybe he mean 12:00 noon (following a definition of Julian time) instead of midnight at the beginning of the day?
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View