SYSTEMTIME 結構
SYSTEMTIME 結構使用月、日、年、週間日、小時、分鐘、秒和毫秒數的個別成員,代表日期與時間。
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
參數
wYear
目前的年度。wMonth
目前月份;一月為 1。wDayOfWeek
目前星期幾:星期日是 0、星期一是 1,依此類推。wDay
月份的目前日期。wHour
目前小時。wMinute
目前的分鐘。wSecond
目前的秒數。wMilliseconds
目前毫秒。
範例
// 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 = _T("Sunday");
break;
case 1:
day = _T("Monday");
break;
case 2:
day = _T("Tuesday");
break;
case 3:
day = _T("Wednesday");
break;
case 4:
day = _T("Thursday");
break;
case 5:
day = _T("Friday");
break;
case 6:
day = _T("Saturday");
break;
}
// Show the time in a message box.
CString str;
str.Format(_T("%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);
需求
**標頭:**winbase.h