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