Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Time
Time Reference
Time Functions
 GetSystemTimeAsFileTime function
GetSystemTimeAsFileTime function

Applies to: desktop apps | Metro style apps

Retrieves the current system date and time. The information is in Coordinated Universal Time (UTC) format.

Syntax

void WINAPI GetSystemTimeAsFileTime(
  __out  LPFILETIME lpSystemTimeAsFileTime
);

Parameters

lpSystemTimeAsFileTime [out]

A pointer to a FILETIME structure to receive the current system date and time in UTC format.

Return value

This function does not return a value.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

File Times
FILETIME
GetSystemTime
System Time
SYSTEMTIME
SystemTimeToFileTime
Time Functions

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
ClockRes      Neil Blackburn   |   Edit   |   Show History
You can run ClockRes from SysInternals to determine your system clock resolution.
Tags What's this?: Add a tag
Flag as ContentBug
15ms resolution      rogerdpack ... Thomas Lee   |   Edit   |   Show History
Warning: this method only returns the time in resolutions of 15ms (0.015s) (at least in XP).

http://msdn.microsoft.com/en-us/magazine/cc163996.aspx
Tags What's this?: Add a tag
Flag as ContentBug
Windows 7 precision      tspitz   |   Edit   |   Show History
Resolution on Windows 7 seems to be sub-millisecond.
Tags What's this?: Add a tag
Flag as ContentBug
Resolution continued      Ian Goldby   |   Edit   |   Show History
As a previous commenter wrote, the resolution of GetSystemTimeAsFileTime() is limited. The actual resolution depends on the system.

On Windows XP and earlier, the resolution is unaffected by timeBeginPeriod(); the value returned by GetSystemTimeAsFileTime() is updated only every tick interval (i.e. 15.625 msecs or 10 msecs depending on hardware and system).

The time at which waitable timers signal though is affected by timeBeginPeriod().

This has the slightly unfortunate result that if you call SetWaitableTimer() with an absolute due time and if any application on the system has reduced the current timer interval by calling timeBeginPeriod(), the timer can appear to signal up to approximately 15 milliseconds early when compared to the current time returned by GetSystemTimeAsFileTime().

In fact the timer has signalled at the correct time; it appears to be early only because the time returned by GetSystemTimeAsFileTime() can be out of date by up to about 15 milliseconds.

Unfortunately there is no straightforward way to get absolute time to the same accuracy as used by waitable timers on systems affected by this problem.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker