VOID GetSystemTime( LPSYSTEMTIME lpSystemTime // address of system time structure ); 其中,SYSTEMTIME定义如下: typedef struct _SYSTEMTIME { // st WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME;
SYSTEMTIME sysTime; GetSystemTime(&sysTime); //GMT time or GetLocalTime(&sysTime); //your time such as BEIJING timethen you can : sysTime.wYear get year, sysTime.wMonth get month, ...for detail see struct: typedef struct _SYSTEMTIME { // st WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME;
CTime m_Time=CTime::GetCurrentTime();
m_Time.GetHour();
m_Time.GetMinute();
m_Time.GetSecond();
LPSYSTEMTIME lpSystemTime // address of system time structure
);
其中,SYSTEMTIME定义如下:
typedef struct _SYSTEMTIME { // st
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
GetSystemTime(&sysTime); //GMT time
or
GetLocalTime(&sysTime); //your time such as BEIJING timethen you can :
sysTime.wYear get year,
sysTime.wMonth get month,
...for detail see struct:
typedef struct _SYSTEMTIME { // st
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
直接用Format函数就可以了