SYSTEMTIME structure (minwinbase.h)
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.
Syntax
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
Members
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.
Remarks
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
- Convert the SYSTEMTIME structure to a FILETIME structure.
- Copy the resulting FILETIME structure to a ULARGE_INTEGER structure.
- Use normal 64-bit arithmetic on the ULARGE_INTEGER value.
Examples
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
Requirements
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) |