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