Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Specifies a date and time, using individual members for the month, day, year, weekday, hour, minute, second, and millisecond. The time is either in coordinated universal time (UTC) or local time, depending on the function that is being called.
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
wYear
The year. The valid values for this member are 1601 through 30827.
wMonth
The month. This member can be one of the following values.
Value | Meaning |
---|---|
|
January |
|
February |
|
March |
|
April |
|
May |
|
June |
|
July |
|
August |
|
September |
|
October |
|
November |
|
December |
wDayOfWeek
The day of the week. This member can be one of the following values.
Value | Meaning |
---|---|
|
Sunday |
|
Monday |
|
Tuesday |
|
Wednesday |
|
Thursday |
|
Friday |
|
Saturday |
wDay
The day of the month. The valid values for this member are 1 through 31.
wHour
The hour. The valid values for this member are 0 through 23.
wMinute
The minute. The valid values for this member are 0 through 59.
wSecond
The second. The valid values for this member are 0 through 59.
wMilliseconds
The millisecond. The valid values for this member are 0 through 999.
Note
The SYSTEMTIME does not check to see if the date represented is a real and valid date. When working with this API, you should ensure its validity, especially in leap year scenarios. See leap day readiness for more information.
It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should
The following example demonstrates the difference between the time values retrieved by the GetSystemTime and GetLocalTime functions.
#include <windows.h>
#include <stdio.h>
void main()
{
SYSTEMTIME st, lt;
GetSystemTime(&st);
GetLocalTime(<);
printf("The system time is: %02d:%02d\n", st.wHour, st.wMinute);
printf(" The local time is: %02d:%02d\n", lt.wHour, lt.wMinute);
}
// Sample output
The system time is: 19:34
The local time is: 12:34
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps | UWP apps] |
Minimum supported server | Windows 2000 Server [desktop apps | UWP apps] |
Header | minwinbase.h (include Windows.h) |
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today