CE取系统时间值

时间:2021-09-09 09:01:50

取时间值:

void GetTime()
{
  //取时间值
    SYSTEMTIME    st    = {};        //    时间结构体
    GetLocalTime(&st);                //    把获取的系统时间信息存储到SYSTEMTIME结构体里面
    CString CStrTime;          //    变量,存储时间
    CStrTime.Format(TEXT("%04d-%02d-%02d %02d:%02d:%02d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wSecond);  AfxMessageBox(CStrTime);
}
typedef struct _SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} SYSTEMTIME, *LPSYSTEMTIME;