SYSTEMTIME Structure

The SYSTEMTIME structure has the following form:

typedef struct _SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} SYSTEMTIME;

The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.

Members

wYear

The current year.

wMonth

The current month; January is 1.

wDayOfWeek

The current day of the week; Sunday is 0, Monday is 1, and so on.

wDay

The current day of the month.

wHour

The current hour.

wMinute

The current minute.

wSecond

The current second.

wMilliseconds

The current millisecond.

Example

// Retrieves the current system date and time.  The system 
// time is expressed in Coordinated Universal Time (UTC). 
SYSTEMTIME systime;
GetSystemTime(&systime);

// Determine day of the week.
CString day;
switch (systime.wDayOfWeek)
{
case 0:
   day = "Sunday";
   break;

case 1:
   day = "Monday";
   break;

case 2:
   day = "Tuesday";
   break;

case 3:
   day = "Wednesday";
   break;

case 4:
   day = "Thursday";
   break;

case 5:
   day = "Friday";
   break;

case 6:
   day = "Saturday";
   break;
}

// Show the time in a message box.
char str[50];
wsprintf(str, "%s %u/%u/%u  %u:%u:%u:%u", 
   day,
   systime.wYear, systime.wMonth, systime.wDay,
   systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);
AfxMessageBox(str);

See Also   CTime::CTime