Training
Module
Get Started with Dates, Times, and Time Zones - Training
Learn how to handle date and time effectively in C# applications.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
System time is the current date and time of day. The system keeps time so that your applications have ready access to accurate time. The system bases system time on coordinated universal time (UTC). UTC-based time is loosely defined as the current date and time of day in Greenwich, England.
When the system first starts, it sets the system time to a value based on the real-time clock of the computer and then regularly updates the time. To retrieve the system time, use the GetSystemTime function. GetSystemTime copies the time to a SYSTEMTIME structure that contains individual members for month, day, year, weekday, hour, minute, second, and milliseconds. It is easy to display this format to a user.
You can also obtain the system time in file time format using the GetSystemTimeAsFileTime function. GetSystemTimeAsFileTime copies the time to a FILETIME structure.
To set the system time, use the SetSystemTime function. SetSystemTime assumes you have specified a UTC-based time.
The GetSystemTimeAdjustment and SetSystemTimeAdjustment functions synchronize the time-of-day clock with another time source using a periodic time adjustment applied at each clock interrupt.
Note that the system can periodically refresh the time by synchronizing with a time source. Because the system time can be adjusted either forward or backward, do not compare system time readings to determine elapsed time. Instead, use one of the methods described in Windows Time.
Training
Module
Get Started with Dates, Times, and Time Zones - Training
Learn how to handle date and time effectively in C# applications.