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
当前的周日期;sunday 为 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);
要求
Header: winbase.h